AngularJS load service then call controller and render

后端 未结 6 1432
生来不讨喜
生来不讨喜 2020-12-28 16:29

My problem is that i need a service loaded before the controller get called and the template get rendered. http://jsfiddle.net/g75XQ/2/

Html:

<
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-28 16:53

    As I said in the comments, it would be a lot easier to handle an unloaded state in your controller, you can benefit from $q to make this very straightforward: http://jsfiddle.net/g/g75XQ/4/

    if you want to make something in the controller when user is loaded: http://jsfiddle.net/g/g75XQ/6/

    EDIT: To delay the route change until some data is loaded, look at this answer: Delaying AngularJS route change until model loaded to prevent flicker

提交回复
热议问题