angular-alert-manager

An angularjs module to manage alerts from anywhere in your application.

Homepage

Added by: Sam Deering

GitHub

Repository

tgillieron/angular-alert-manager

Stats

Stars: 0

Watchers: 0

Forks: 0

Author

Thomas
Thomas

Module Description

angular-alertManager

An angularjs module to manage alerts from anywhere in your application. Build Status Dependency Status

Installation

~~Download the file through bower :~~

bower install angular-alertManager

Add the dependencies on amAlerts module:

angular.module('app', ['amAlerts']);

To be fully functional you need to include the twitter bootstrap CSS or implement the alerts' classes.

Demo

To see the directives and service in action : http://tgillieron.github.io/angular-alertManager

Documentation

amAlert directive

The amAlert directive let you create a single alert anywhere on your html page.

Attributes

  • type : string one in success, info, warning or danger to select the style to apply on the alert.
  • close : function to close the alert.
  • delay : integer a time in millisecond to wait before closing the alert. ! the close attribute must be defined for the alert to close.
  • hide : boolean to force the close button to be hidden.

type are also available as constants in through the AM_TYPES variable.

amAlerts directive & service

Used in conjunction they allow to manage alerts from anywhere in the application

How to use it

  • Add the amAlerts in your html page:
<am-alerts></am-alerts>

You can add it to how many pages/templates you whant but it should only apears once in the rendered page.

  • Inject the amAlerts service in your controllers/services and use the add methode to render new alerts:
app.controller('myController', [ 'amAlertsService', ...

amAlerts service api

  • alerts : array of the alerts to be displayed.
  • close(index) : function to close an alert by its position in the array.
  • clear() : function to remove all alerts from the array.
  • add(type, message, options) : function to add a new alerts to the array.
    • type: string one in success, info, warning or danger to select the style to apply on the alert.
    • message: string representing the message to display in the alert.
    • options: object to alter the alert behaviour. see next section for details.

Options

  • html : boolean to trust or not html content in the message string.
  • close: boolean whenever the alert is closable.
  • delay: integer a time in millisecond to wait before closing the alert.
  • hide: boolean to force the close button to be hidden.
  • status: AM_STATUS one in:
    • ON_NEXT : will be displayed on the next page. Useful when you add an alert just before changing the url as it might be rendered a first time on the previous page.
    • UNSEEN : the default status on creation. it will passe to SEEN after the first rendering of the alert.
    • SEEN : the alert will be removed on the next url change.
    • PERMANENT : the alert will never be removed automatically from the array.

TIPS: Apart from PERMANENT, status are in fact integer with UNSEEN = 0. If you want to create a alert that disappear after 3 url change, you can set is status to ON_NEXT -2.

Module stats last updated: 2015-04-15 19:44:29

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!