[ AngularJS] angular-growl-v2

Config

var app = angular.module('myApp', ['angular-growl']);

app.config(['growlProvider', '$httpProvider', function(growlProvider, $httpProvider) {
growlProvider.globalTimeToLive(5000);

growlProvider.globalDisableCountDown(true);

}]);

Handling Server Sent Notifications

$httpProvider.interceptors.push(growlProvider.serverMessagesInterceptor);

On every HTTP request and looks if response contains messages.

Interceptor looks in response for a messages array of objects with text, title and severity key. This is an example response which results in 3 growl messages.

Example HTTP response

{
"someOtherData": {...},
"messages": [
{"text":"this is a server message", "severity": "warn"},
{"text":"this is another server message", "severity": "info"},
{"text":"and another", "severity": "error", "title" : "Server side errors!"}
]
}

ref : http://janstevens.github.io/angular-growl-2/#time-to-live-countdown

Alert Error notification

myApp.factory('whatever', ['growl', function(growl){

growl.error("error message");

}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s