sample.service('notifications', ['$rootScope', function ($rootScope) { var queue = []; return { queue: queue, add: function (item) { var index = -1; //check alert with same body not active in dom for (var i = 0; i < this.queue.length; i++) { if (queue[i].body == item.body) { index = i; break; } } if (index != -1) return; queue.push(item); setTimeout(function () { $('.alerts .alert').eq(0).remove(); queue.shift(); }, 3000); }, pop: function (item) { var index = -1; //to find alert from queue of active alerts in dom for (var i = 0; i < this.queue.length; i++) { if (queue[i].body == item) { index = i; break; } } if (index != -1) queue.splice(index, 1); return this.queue; } }; } ]);
//Controller sample.controller('notifyController', function ($scope, notifications) {
$scope.notify = notifications; $scope.closeAlert = function (item) { notifications.pop(item); }
$scope.info = function () { setNotification(notifications, 'info', 'information', 'TOUS LES BIENFAITS D’UN MASSAGE RELAXANT AROMATIQUE'); }
$scope.success = function () { setNotification(notifications, 'success', 'Success ', 'Success isn’t the matter of being the best'); }
$scope.warning = function () { setNotification(notifications, 'warning', 'Warning ', 'If I have received a suspicious message, what should I do?'); }
$scope.error = function () { setNotification(notifications, 'danger', 'Error ', 'No I don’t keep secrets from mom and dad.'); } });
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
you can also use the following link:
https://www.jqueryscript.net/other/Simple-Multipurpose-Growl-Notification-Plugin-With-jQuery-notifier.html