I am trying to understand the life cycle of angular services and components.
Let's say I have a controller that uses the http service:
function MyController($scope, $http) {
$http.get('/service').success(function(data) {
});
}
The fact is that this controller can be attached to the view. And I want to make sure that the response is discarded, if the view has been deleted, this prevents conflicts with other requests that can be launched in other parts of the application. Will the controller instance be destroyed and with it, the services waiting for the call $httpwill be canceled if the view is deleted? For example, when a user moves (without reloading) from a page, causing Javascript to render a new section?
[ Edit ] I created jsfiddle , which shows that, at least for the $ timeout service, pending operations still work after they $scopeare destroyed during navigation. Is there an easy way to bind async operations to scope so that they are automatically destroyed?
source
share