Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
angular-notification
Advanced tools
Notification service for Angular using native HTML5 API.
bower install angular-notification
npm install angular-notification
angular.module('controllers.notification', ['notification'])
.controller('NotificationCtrl', function ($notification) {
$notification('New message', {
body: 'You have a new message.'
});
})
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:
null
.true
.$notification('title', {
body: 'message',
dir: 'auto',
lang: 'en',
tag: 'my-tag',
icon: '/my-icon.jpg',
delay: 1000, // in ms
focusWindowOnClick: true // focus the window on click
})
Set default options.
$notificationProvider.setOptions({icon: '/my-icon.jpg'});
Close the notification.
var notification = $notification('hello');
notification.close();
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 = $notification('hello');
var deregister = notification.$on('click', function () {
console.log('User has clicked.');
});
// Stop listening the event.
deregister();
Request explicitly the permission to display notification, more info in the official API.
$notification.requestPermission()
.then(function (permission) {
console.log(permission); // default, granted, denied
});
MIT
FAQs
Notification service for Angular using native HTML5 API.
The npm package angular-notification receives a total of 159 weekly downloads. As such, angular-notification popularity was classified as not popular.
We found that angular-notification demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.