i like to show an alert box every time a request is done. To shorten my way i like to use the 'Bootstrap Alert'. There seems to be no way to access on any scope inside a factory. How can i realize something like this ?
app.factory('httpInterceptor', function ($q) {
return {
// On request success
request: function (config) {
$scope.alerts.push({msg: "Request done !"}); //There is no scope
return config || $q.when(config);
},
// On request failure
requestError: function (rejection) {
return $q.reject(rejection);
},
// On response success
response: function (response) {
return response || $q.when(response);
},
// On response failure
responseError: function (rejection) {
return $q.reject(rejection);
}
};
});
See Alert Example on http://angular-ui.github.io/bootstrap/