ng-bootstrap-alert

An Angular service for displaying Bootstrap Alerts
Homepage:
0 people use it
Submitted by: 139790?v=3 8bitDesigner

ng-bootstrap-alerts

ng-bootstrap alerts is a service for displaying Rails-style flash notifications as Bootstrap alerts.

Installation

In your Angular project, run bower install --save ng-bootstrap-alerts to save the module. Then, in your HTML, add the script tag for ng-bootstrap-alerts:

And lastly, in your Angular module, include ng-bootstrap-alerts as a dependency:

Usage

TL;DR

If you use Rails' flash messages, add the alert placeholder to the top of your page:

And then load any flash alerts into our alertsProvider

And lastly, while your app is running, you can create alerts on the fly with:

Alert types

Alerts have a type corresponding to the list of Bootstrap alert types, but we also coerce a couple of common of Rails flash types into Bootstrap types:

Different alert types

API

alertsProvider#queue(message, type [, optionsObject])

The alertsProvider service has one method queue, which allows you to, at config-time, preload alerts, with an optional type:

Supported options

  • dismissAfter: intMilliseconds
    Automatically dismisses the alert after a number of milliseconds

alerts#create(message, type [,optionsObject])

The alerts service's create method, lets you do the same during your app's run cycle:

Supported options

  • dismissAfter: intMilliseconds
    Automatically dismisses the alert after a number of milliseconds

alerts#dismiss(alert)

The dismiss method, lets you remove an existing alert from the page:

The alert-list directive

Lastly, the alert-list directive will display the any alerts in the alerts service:

Contributing

To get your dev environment up and running, run npm install and bower install to get the components we need.

Tests are run with npm run test against the minified source (to catch Angular annotation errors). You can build the minified file as you work by running npm run build:watch

Releases are built using npm run release:[type]. So, to generate a new patch release, run npm run release:patch. This script will:

  • Generate minified, concatenated JS files,
  • Increment the version in bower.json
  • Tag a new release
comments powered by Disqus
This page was last updated over 2 years ago.