This is just to brainstorm some things; let me know if I'm crazy and on the 
wrong path of thinking. So I have /payments and /settings as routes as an 
example. I go to /payments and the payments controller loads with the view. 
I go to /settings and the settings controller loads with the view. I go 
back to /payments and again the controller reloads with the view. 
Everything in the controller is reinitialized, but this controller is being 
used no where else in the application. So what do we do? We cache the data 
being returned in ajax calls in a service and if they reload the controller 
the service will check to see if it is already cached and if it is return 
the cached values. Another thing is if I am trying to keep track of state 
in that controller I need to store more data in the service. So now for the 
payments controller I have a  payments service which is responsible for 
making all the payments related ajax calls and for caching data that the 
controller would need to keep track of state.

I feel like there should be an option to cache controllers than to always 
reinitialize them because then you don't have to cache data in services you 
are using for controllers and reinitialize the controllers every time. 

If I press the back button, I'm going back to a previous state in the 
application. It seems weird that going back will actually reinitialize the 
controller and the data being displayed on the page could be different 
(this case would happen if you aren't caching everything in the service). 

Let me know what you guys think.

Jon

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to