alexcrack / angular-ui-notification

Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating
MIT License
536 stars 169 forks source link

can't be injected #116

Open HamadaRizk opened 7 years ago

HamadaRizk commented 7 years ago

the service can not be injected in another custom service

nadouani commented 7 years ago

@HamadaRizk I'm not sure to understand why you cannot inject the service in another one. I'm using a wrapper around it and it works fine

HamadaRizk commented 7 years ago

can you send me a demo please @nadouani

nadouani commented 7 years ago

You can find an example here https://plnkr.co/edit/LJhe1FFj1A3ZRv6RDrwg?p=preview

angular.module('NotificationApp', ['ui-notification'])
  .factory('CustomNotification', ['Notification', function(Notification){
    return {
      success: function(message) {
        Notification.success(message);
      }
    };
  }])
  .controller('MainCtrl', ['Notification', 'CustomNotification', function(Notification, CustomNotification) {

    this.showNotification = function() {
      Notification.success('Success notification');
    };

    this.showWrappedNotification = function() {
      CustomNotification.success('Custom notification');
    };

  }]);