我可以使用以下语法在 Controller 中使用上面提到的模块,但是当尝试在服务中使用它时它不起作用。
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
}
});
最佳答案
您不应显示来自服务的UI 通知。您可以使用回调或事件来通知控件“某事”(在您的情况下它似乎是文件上传)已经发生。然后 UI Controller 将显示通知弹出窗口。
关于angularjs - 在 angular.service 中使用 Angular 用户界面通知而不是 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38368594/