2016-07-14 12 views
3

Ich bin in der Lage, oben genannten Modul in Controller mit unten Syntax zu verwenden, aber während versuchen, im Dienst zu verwenden es funktioniert nicht.Verwende angular-ui-notification im Anuglar-Dienst anstelle des Controllers?

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 offizielle URL: https://github.com/alexcrack/angular-ui-notification

Antwort

0

Sie sollten nicht UI Benachrichtigungen von Diensten anzuzeigen. Sie können einen Rückruf oder ein Ereignis verwenden, um das Steuerelement zu benachrichtigen, dass "etwas" (in Ihrem Fall scheint es ein Datei-Upload zu sein) passiert ist. dann zeigt der UI-Controller das Benachrichtigungs-Popup an.