3

I am able to use above mentioned module in controller with below syntax but while try to use same in service its not working.

 app.controller('regulationCtrl', function ($scope, $rootScope, $http, $window, $location,Notification) {
           Notification.primary({message: "Some error message", templateUrl: "custom_template.html", scope: $scope}); 
 //THIS CODE WORKS FINE
});

 app.service('fileUploadRegulations',  function ($http,Notification, $rootScope) {
    this.uploadFileToUrl = function (file, country, juridiction, uploadUrl,Notification) {
    Notification.primary({message: "Some error msg:", templateUrl: "custom_template.html", scope: $scope});
 //THIS CODE NOT WORKING
 }
 });

Plugin official URL: https://github.com/alexcrack/angular-ui-notification

1 Answers1

0

You should not display UI notifications from services. You can use a callback or an event to notify the control that "something" (in your case it appears to be a file upload) has happened. then the UI controller will show the notification popup.

Liviu Mandras
  • 6,540
  • 2
  • 41
  • 65