Issue
As we work in angular when we route from one url to another then controller data is Rest but service data is not reset.
Can someone please explain why its not reset. Any help is appreciated.
Thanks
Solution
Services are only instantiated once and every component depending on the service gets the same shared instance of it. Services are not "reset"/destroyed/torn down, they're permanent. Controllers are bound to scopes and come and go with the scope.
This in fact allows you to have a constant "backend" in the form of services which retain their state throughout the entire life cycle of the app, while controllers are temporary things bound to views which come and go as the GUI changes.
Answered By - deceze
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.