angular-flash
A simple lightweight flash message module for AngularJS and Bootstrap.
Demo
angular-flash | jsfiddle | codepen
How to use
npm
You can also find angular-flash on npm
$ npm install angular-flash-alert
Bower
You can Install angular-flash using the Bower package manager.
$ bower install angular-flash-alert --save
Add the Following code to the <head> of your document.
<link type="text/css" rel="stylesheet" href="dist/angular-flash.min.css" />
// If you are using bootstrap v3 no need to include angular-flash.css
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="dist/angular-flash.min.js"></script>
// Do not include both angular-flash.js and angular-flash.min.js
Add ngFlash
dependency to your module
var myApp = angular.module("app", ["ngFlash"])
Include directive below in your HTML template.
<flash-message duration="5000" show-close="true" on-dismiss="myCallback(flash);"></flash-message>
Inject the Flash
factory in your controller
myApp.controller('demoCtrl', ['Flash', function(Flash) {
$scope.successAlert = function () {
var message = '<strong>Well done!</strong> You successfully read this important alert message.';
var id = Flash.create('success', message, 0, {class: 'custom-class', id: 'custom-id'}, true);
}
}]);
####Flash types####
Methods
These methods are mostly for internal usage but can be used also from outside.
Flash.dismiss(1);
Flash.clear();
Animating
You can animate the flash messages via traditional Angular way by including ngAnimate as a dependency of your application and then defining the CSS transitions for different classes (ng-enter, ng-move, ng-leave) provided by Angular.
Example:
.alert.ng-leave {
opacity: 1;
transition: opacity 1.5s ease-out;
}
.alert.ng-leave-active {
opacity: 0;
}
Running tests
npm install
./node_modules/karma/bin/karma start
Contributors
License
MIT © Sachin Choluur