npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bedrock-angular-alert

v4.0.0

Published

An AngularJS module that provides a service for managing alerts.

Downloads

16

Readme

bedrock-angular-alert

An AngularJS module that provides a service for managing alerts (errors, warnings, feedback information, etc.) for bedrock-angular and directives for displaying those alerts.

Quick Examples

<!-- display all logged alerts -->
<div br-alerts br-fixed="true"></div>

<!-- custom directive that uses brAlertService -->
<my-directive></my-directive>
angular.module('example', ['bedrock.alert']).directive('myDirective', factory);

/* @ngInject */
function factory(brAlertService) {
  return {
    restrict: 'E',
    scope: {},
    template: '<button ng-click="errorOccurred()">Error</button>',
    link: (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});
      };
    }
  };
}

Setup

npm install bedrock-angular-alert

bedrock-angular-alert must be added to the bedrock.browserDependencies list in the package.json file of the dependent package.

To manually add bedrock-angular-alert as a dependency:

angular.module('myapp', ['bedrock.alert']);

API

brAlertService.category

An object that stores the available alert categories: FEEDBACK and BACKGROUND.

brAlertService.log

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.

brAlertService.on(event, listener)

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.

brAlertService.removeListener(event, listener)

Removes a particular event listener.

brAlertService.add(type, value, [options])

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.

brAlertService.remove(type, value)

Removes the given alert, regardless of which category it is in.

brAlertService.clear([type], [category])

Clears all alerts of a given type or all alerts of a given type in a particular category.

brAlertService.clearFeedback([type])

Clears all feedback alerts or feedback alerts of a particular type.