https://github.com/gtramontina/angular-flash
Flash messages for Angular.js
https://github.com/gtramontina/angular-flash
Last synced: 2 months ago
JSON representation
Flash messages for Angular.js
- Host: GitHub
- URL: https://github.com/gtramontina/angular-flash
- Owner: gtramontina
- Created: 2013-05-24T15:38:25.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2016-12-20T12:12:22.000Z (over 8 years ago)
- Last Synced: 2025-04-07T00:09:17.841Z (2 months ago)
- Language: JavaScript
- Homepage: http://goo.gl/Rcfgyw
- Size: 288 KB
- Stars: 99
- Watchers: 8
- Forks: 29
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# angular-flash
[](https://bitdeli.com/free "Bitdeli Badge")
[](https://travis-ci.org/gtramontina/angular-flash)Flash messages for Angular.js. [Demo](http://embed.plnkr.co/y1INk36bPbW7GaX15QbQ/preview)
Supports view changes, which means you can set a flash message, navigate to another view and your message will be displayed.
## Install
`bower install angular-flash-messages`## Usage
After adding `angular-flash.js` to your project, add `flash` as a dependency to your module. Here is a simple example:```javascript
angular.module('myModule', ['flash'])
.controller('EditProductController', function($scope, flash) {
$scope.save = function() {
// … save the product
flash('Saved!');
};
});
```Then, in your HTML, simply add the `` element where you want your messages to be displayed. It can be in your main template or individual partials.
```html
Home
```### IE Support
If you need IE8 support (or prefer), you can use the attribute directive: ``.
## Examples
- `flash('My message')`
```html
- My message
```- `flash([ 'Hi!', 'My message' ])`
```html
- Hi
- My message
```- `flash('error', 'Something went wrong…')`
```html
- Something went wrong…
```- `flash([ 'Hi!', { level: 'warning', text: 'This is a warning!' } ])`
```html
- Hi
- This is a warning!
```## License
This is licensed under the feel-free-to-do-whatever-you-want-to-do license.