Javascript 无法读取未定义的属性“$on”
试图在AngularJS中使用事件,但得到标题中声明的错误 这看起来很直截了当,所以不确定是什么导致了错误 我的代码:Javascript 无法读取未定义的属性“$on”,javascript,html,angularjs,angularjs-scope,Javascript,Html,Angularjs,Angularjs Scope,试图在AngularJS中使用事件,但得到标题中声明的错误 这看起来很直截了当,所以不确定是什么导致了错误 我的代码: .controller('FooterCtrl', [function($scope) { var showTime = false; $scope.$on('flip', function (event, args) { showTime = !showTime; }); }]); .controller('View3Ctrl
.controller('FooterCtrl', [function($scope) {
var showTime = false;
$scope.$on('flip', function (event, args) {
showTime = !showTime;
});
}]);
.controller('View3Ctrl', [function($scope) {
$scope.$emit('flip', args);
}]);
是否有人知道如何修复此错误及其含义?为什么$scope没有定义
.controller('FooterCtrl', ["$scope",function($scope) {
var showTime = false;
$scope.$on('flip', function (event, args) {
showTime = !showTime;
});
}]);
.controller('View3Ctrl', ["$scope",function($scope) {
$scope.$emit('flip', args);
}]);
试试这一个可能重复的