Why should the request data be placed in run? js must pay attention to asynchronous issues.
You can request data through ajax in the controller (it is recommended to use $http). Before the data comes back, put a loading circle on the page. After the data comes, it will be refreshed to the page and the loading will be hidden.
You can also use the resolve attribute of the route. This is to wait until the data is obtained before loading the page. Please refer to the routing tutorial for specific usage.
Both methods are very easy to use, I personally like the first one.
Why should the request data be placed in run? js must pay attention to asynchronous issues.
You can request data through ajax in the controller (it is recommended to use $http). Before the data comes back, put a loading circle on the page. After the data comes, it will be refreshed to the page and the loading will be hidden.
You can also use the resolve attribute of the route. This is to wait until the data is obtained before loading the page. Please refer to the routing tutorial for specific usage.
Both methods are very easy to use, I personally like the first one.
Resovle in the router
You can get the promise requested by ajax during run in the controller, and then write the code in the then callback.
You can also watch the user information you want in the controller, and then execute your logic when there is value.
You can define a variable ok after the run ajax is completed to identify whether success
In the controller
function waitOK() {
}