Angular (1.0.8) $ routeProvider
can resolve the promises before redirecting the controller. I have a general functionality (in a service) that should be accessed with two separate links. I can add the same resolution for two different paths in the $ routeProvider
but this duplication Is there any way to resolve the promises before making the service?
As Mavalam said, the services are secluded since you have not given the code at all, the answer is not correct But the concept will be.
You can do something like this in your service:
this.userData = false; Return {init: function (id) {fetchStuffForTheUser (id) Then (function (feedback) {this.userData = response;}); }, GetUserData: function () {return userData; }}
init
will obtain user data and store it in the this.userData for the entire session. After this,
getUserData will always return the data that you call it to the controller.
Comments
Post a Comment