JanStevens / angular-growl-2

growl-like notifications for angularJS projects
MIT License
285 stars 97 forks source link

Responsive interceptor error used to work in angular-growl - did this get removed? #36

Closed cccastle closed 10 years ago

cccastle commented 10 years ago

All my services return a response object which has a view model and a message list called Messages

In angular-growl I could set it up using this code....

app.config(["growlProvider", "$httpProvider", function(growlProvider, $httpProvider) { growlProvider.globalTimeToLive(3000); growlProvider.messagesKey("Messages"); growlProvider.messageTextKey("MessageText"); growlProvider.messageSeverityKey("SeverityLevel"); growlProvider.onlyUniqueMessages(true); $httpProvider.responseInterceptors.push(growlProvider.serverMessagesInterceptor); }]);

now I get this error

TypeError: object is not a function at $get.reversedInterceptors.splice.response (http://localhost:61561/Scripts/angular.js:7546:18) at deferred.promise.then.wrappedCallback (http://localhost:61561/Scripts/angular.js:11561:81) at deferred.promise.then.wrappedCallback (http://localhost:61561/Scripts/angular.js:11561:81) at http://localhost:61561/Scripts/angular.js:11647:26 at Scope.$get.Scope.$eval (http://localhost:61561/Scripts/angular.js:12673:28) at Scope.$get.Scope.$digest (http://localhost:61561/Scripts/angular.js:12485:31) at Scope.$get.Scope.$apply (http://localhost:61561/Scripts/angular.js:12777:24) at http://localhost:61561/Scripts/angular.js:1447:15 at Object.invoke (http://localhost:61561/Scripts/angular.js:3966:17) at doBootstrap (http://localhost:61561/Scripts/angular.js:1445:14)

I have tried with angular 1.2 and 1.3 and both give the same error

Is there a new way to set up this functionality?

JanStevens commented 10 years ago

Hello,

Your method is deprecated, the following code is the new way of adding interceptors. Following link has the latest updated version and documentation: http://janstevens.github.io/angular-growl-2/

app.config(['growlProvider', '$httpProvider', function(growlProvider, $httpProvider) {
  $httpProvider.interceptors.push(growlProvider.serverMessagesInterceptor);
}]);