我在控制器中有以下内容。
$rootScope.$on('progressbarEvent', function (event, data) {
$rootScope.progresscurrent = data.currentprogress;
console.log('Event listening: ' + $rootScope.progresscurrent);
});
I have this in a factory service.
$rootScope.$emit('progressbarEvent', dataFactory.currentprogress);
$ on返回undefined。谁知道这个的原因?
我的控制器是:
app.controller('indexcontroller', ['$rootScope','$scope', '$http', 'dataFactory',
function ($scope,$http,$rootScope, dataFactory) {
答案 0 :(得分:24)
依赖关系的顺序必须与声明的数组一致:
app.controller('indexcontroller', ['$rootScope','$scope', '$http', 'dataFactory',
function ($rootScope, $scope, $http, dataFactory) {