Name: bedrock-angular-alert
Owner: Digital Bazaar, Inc.
Description: Bedrock AngularJS Alerts
Created: 2015-01-21 22:21:53.0
Updated: 2017-09-09 01:33:45.0
Pushed: 2017-11-06 17:43:20.0
Homepage: null
Size: 35
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
An AngularJS module that provides a service for managing alerts (errors, warnings, feedback information, etc.) for bedrock-angular and directives for displaying those alerts.
display all logged alerts -->
br-alerts br-fixed="true"></div>
custom directive that uses brAlertService -->
directive/>
s
lar.module('example', ['bedrock.alert']).directive('myDirective', factory);
ngInject */
tion factory(brAlertService) {
turn {
restrict: 'E',
scope: {},
template: '<button ng-click="errorOccurred()">Error</button>',
link: function(scope, element) {
brAlertService.add('info', 'myDirective loaded.');
scope.errorOccurred = function(err) {
// add a feedback error; if the scope is destroyed, remove the error
brAlertService.add('error', err, {scope: scope});
};
}
r install bedrock-angular-alert
Installation of the module followed by a restart of your bedrock server is sufficient to make the module available to your application.
To manually add bedrock-angular-alert as a dependency:
lar.module('myapp', ['bedrock.alert']);
An object that stores the available alert categories: FEEDBACK
and
BACKGROUND
.
A categorized log of alerts. brAlertService.log
is an object where each
entry has a key from brAlertService.category
and a value that is an array of
alerts that have been added for that category.
Adds a listener for the given type of event. The valid event types are:
add
, remove
, and clear
. The add
event is emitted when an alert is
added, remove
is emitted when an alert is removed, and clear
is emitted
when alerts of a particular type and/or category are cleared.
Removes a particular event listener.
Adds an alert to the log.
The alert type may be error
, warning
, or info
.
The value can be a string, an Error
instance, or an object with an html
property set to custom html
to be displayed, for example, by a
br-alerts
directive.
If options are provided, they may include a category
from
brAlertService.category
and/or a scope
. If no category
is given, the
default, brAlertService.category.FEEDBACK
will be used. If a scope
is
given, then when the scope
is destroyed, the alert will be removed. This
is useful for removing feedback generated from UI elements that can be
destroyed. For example, a modal that generates feedback alerts may be closed,
and if the alerts were added using the modal's scope, the alerts will be
automatically removed.
Removes the given alert, regardless of which category it is in.
Clears all alerts of a given type or all alerts of a given type in a particular category.
Clears all feedback alerts or feedback alerts of a particular type.