A simple flash notification module made up of a factory and a directive that will display flash messages using AngularJS. The directive uses pure-extras for styling of the alerts.
Download angular-flash-pure.min.js and pure-extras.css or install it with bower.
$ bower install angular-flash-pure --save
Load the module into your app
var myApp = angular.module('myApp', ['angular-flash-pure']);
Use the flash factory to set flash messages
myApp.controller('myController', ['flash', '$location', function(flash, $location){
flash.notice.setMessage("I'm a flash notification!"); // error, success, and warning also work
$location.path('/some/path');
}]);
Then in one of your views
<flash-messages></flash-messages>
And then it all works!
So the display of flash notifications are triggered by $locationChangeStart
. But I'm aware that isn't always what you want. So if you would like the
notification to appear without changing location, do the following when you want
them to be displayed:
$rootScope.$emit("event:angularFlash");
Check out the Plunker. This demo uses the manual triggering of flash events.
For this project, we use Bower, Grunt, and Coffeescript.
$ grunt build