An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

        

# angular-flash
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/gtramontina/angular-flash/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
[![Build Status](https://travis-ci.org/gtramontina/angular-flash.png?branch=master)](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


    1. My message


    ```

    - `flash([ 'Hi!', 'My message' ])`

    ```html


    1. Hi

    2. My message


    ```

    - `flash('error', 'Something went wrong…')`

    ```html


    1. Something went wrong…


    ```

    - `flash([ 'Hi!', { level: 'warning', text: 'This is a warning!' } ])`

    ```html


    1. Hi

    2. This is a warning!


    ```

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