Skip to content

h3xed/angular-flash

 
 

Repository files navigation

angular-bootstrap-flash

Bootstrap 3 flash messages for Angular.js.

Usage

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>

IE Support

If you need IE8 support (or prefer), you can use the attribute directive: <div flash:messages></div>.

Examples

  • 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>

License

This is licensed under the feel-free-to-do-whatever-you-want-to-do license.

About

Flash messages for Angular.js

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 61.0%
  • HTML 36.2%
  • Makefile 2.8%