Fire notification toaster in any controller angularjs

前端 未结 3 1653
名媛妹妹
名媛妹妹 2020-12-14 03:53

I am using this service for notifications: https://github.com/jirikavi/AngularJS-Toaster
Is working perfectly. Already configured for that anywhere in my application I c

3条回答
  •  醉梦人生
    2020-12-14 04:20

    I like @AndreiC's answer. A year later, here is a more robust factory service I use:


    .factory('notifierService',function(toaster){
        return{
            notify: function(msg){
                    toaster.pop('success', 'Update Successful', 'The ' + msg + ' setting was updated');
            },
            notifyError: function(msg){
                    toaster.pop('error', 'Something Went Wrong', 'Please check with an administrator');
            },
            notifyInfo: function(msg){
                    toaster.pop('info', 'Information', 'The ' + msg + 'just happened' );
            }
        };
    })
    
    on the $resource promise
    .$promise.then(function() {
         notifierService.notify('email server');
     });
    

提交回复
热议问题