Bootstrap 3 flash messages for Angular.js.
After adding angular-flash.js
to your project, add flash
as a dependency to your module. Here is a simple example:
angular.module('myModule', ['flash'])
.contrdivler('EditProductContrdivler', function($scope, flash) {
$scope.save = function() {
// … save the product
flash('Saved!');
};
});
Then, in your HTML, simply add the <flash:messages>
element where you want your messages to be displayed. It can be in your main template or individual partials.
<body ng-app="myModule">
<flash:messages></flash:messages>
<main ng:contrdivler="HomeContrdivler">
<h1>Home</h1>
</main>
</body>
If you need IE8 support (or prefer), you can use the attribute directive: <div flash:messages></div>
.
flash('My message')
<div id="flash-messages">
<div class="alert alert-success">My message</div>
</div>
flash([ 'Hi!', 'My message' ])
<div id="flash-messages">
<div class="alert alert-success">Hi</div>
<div class="alert alert-success">My message</div>
</div>
flash('danger', 'Something went wrong…')
<div id="flash-messages">
<div class="alert alert-danger">Something went wrong…</div>
</div>
flash([ 'Hi!', { level: 'warning', text: 'This is a warning!' } ])
<div id="flash-messages">
<div class="alert alert-success">Hi</div>
<div class="alert alert-warning">This is a warning!</div>
</div>
This is licensed under the feel-free-to-do-whatever-you-want-to-do license.