Reputation: 1259
I have the following provider in my app.js main file:
.provider('securityInterceptor', function() {
this.$get = function($location, $q) {
return function(promise) {
return promise.then(null, function(response) {
if(response.status === 403 || response.status === 401) {
$location.path('/unauthorized');
}
return $q.reject(response);
});
};
};
})
But there seems to be a problem when minifying this. I found out that it's because of $location and $q. How can I safely inject those in the function? Using something like the following doesn't help (actually it's not applicable):
this.$get = function(['$location', '$q'], $location, $q) {
...
}
or
.provider('securityInterceptor', ['$location', '$q', function ($location, $q)... ]
How can I safely inject these dependencies? I'm using ASP .NET MVC's BundleConfig.
Upvotes: 2
Views: 58
Reputation: 211
Use this variant:
this.$get = ['$location', '$q', function($location, $q) {
...
}];
See more info here: https://docs.angularjs.org/guide/providers
Upvotes: 2