Я не могу получить доступ к $ rootScope внутри поставщика. Я искал много вариантов угловых других модулей. это то же самое, что и я. Что не так? он пытался urload в виде отдельной функции (по аналогии с другой функцией ПолучитьЗначение) она не работает
Ошибка в $ испускают неопределен
define(['angularAMD'], function() {
var contextServiceModule = angular.module('contextService', []);
var contextService = function() {
var context = {};
this.$get = ['$rootScope', function ($rootScope) {
console.log($rootScope);
return function(){
return {
init: init,
getValue: getValue,
setValue: setValue,
urlLoad: function() {
$rootScope.$emit('onInit', {});/// error here
}
};
};
}];
this.init = function() {
return context;
};
this.getValue = function (key) {
var value = context[key] ? context[key] : null;
return value;
};
this.setValue = function (key, value) {
context[key] = value;
};
}
contextServiceModule.provider('contextService', contextService);
});