angular-notification
Notification service for Angular using native HTML5 API.
Install
Using bower
bower install angular-notification
Using npm
npm install angular-notification
Usage
angular
$notification(title, options)
Create a new notification, the signature is the same as the Web Notification API.
Angular-notification provides some sugar to the default API, the permission is requested automatically. There is some options in addition to that already present in the official API:
- "delay": Specify a delay (in ms) after the notification is automatically closed. Default
null
. - "focusWindowOnClick": Focus the window when the notification is clicked (works only on Chrome, Firefox prevent this for security issue). Default
true
.
$notificationProvider.setOptions(options)
Set default options.
$notificationProvider;
notification.close()
Close the notification.
var notification = ;notification;
notification.$on(name, listener)
Listen an event on the notification. Using this method, the listener is automatically wrapped in an $apply()
.
The signature is the same as the angular $scope.$on
signature, it returns the deregistration function.
Avalaible examples are 'click', 'show', 'close' and 'error'.
var notification = ;var deregister = notification; // Stop listening the event.;
$notification.requestPermission()
Request explicitly the permission to display notification, more info in the official API.
$notification;
License
MIT