Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gghez/angular-notification-service
Simple notification service for AngularJS application
https://github.com/gghez/angular-notification-service
Last synced: about 1 month ago
JSON representation
Simple notification service for AngularJS application
- Host: GitHub
- URL: https://github.com/gghez/angular-notification-service
- Owner: gghez
- Created: 2015-03-20T19:41:14.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-09-03T11:50:02.000Z (over 9 years ago)
- Last Synced: 2024-11-09T10:41:41.609Z (about 2 months ago)
- Language: JavaScript
- Size: 148 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# angular-notification-service
Simple notification service for AngularJS application## Why
Because there is no such service provided by AngularJS and at least me need it.
## Installation
```
bower install --save angular-notification-service
```## Usage
Load script using `` HTML tag like you do with angular.
```html
<script src="assets/libs/angular-notification-service/notificationService.js">
```Add as reference to your application module.
```js
angular.module('yourmodule', ['ng', 'angularNotification']);
```Use it in directive, service, filter or controller:
*Consumer*
```js
angular.module('yourmodule').controller('mycontroller', ['$scope', 'Notification', function($scope, Notification) {function onNotification(my, args, here) {
}Notification.register('alerts', onNotification);
$scope.$on('destroy', function(){ Notification.unregister('alerts', onNotification); });
}]);
```*Producer*
```js
angular.module('yourmodule').service('myalerts', ['Notification', function(Notification) {return {
alert: function(my, args, here) {
Notification.notify('alerts', my, args, here);
}
};}]);
```The `'alerts'` string is a channel on which you can raise notification or listen to. Channels are created as soon as at least one consumer has registered a callback on.