javascript - How to assign values ​​to variables using the data returned by angular http
过去多啦不再A梦
过去多啦不再A梦 2017-05-24 11:33:22
0
3
680

How to get rid of the asynchronous problem. The http request will return the data number, and then use this number globally. However, due to asynchronous reasons, the assignment variable of this number is always undefined. How to deal with this

过去多啦不再A梦
过去多啦不再A梦

reply all(3)
洪涛

Place the request in mainCtrl.

淡淡烟草味

I have encountered this before, but we are using an http service written by ourselves, which returns a promise object, so we have to use then to obtain the data inside. I looked at this method written by a colleague, and it seems that it returns the response.data of http in Angular. I don’t know if this will help you

滿天的星座

Put the logic code that will use the data into the callback function of the asynchronous request success to ensure that the data has been obtained when the code that needs to use the data is executed.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template