TypeError:无法读取属性';手表';在angularjs ng idle中未定义?
我试图在登录控件中写入空闲超时问题,但是我得到了undefined的cannotread属性'watch' 我试图在Tomcat服务器7和Angular 1.5中执行以下代码TypeError:无法读取属性';手表';在angularjs ng idle中未定义?,angularjs,ng-idle,Angularjs,Ng Idle,我试图在登录控件中写入空闲超时问题,但是我得到了undefined的cannotread属性'watch' 我试图在Tomcat服务器7和Angular 1.5中执行以下代码 $scope.started = false; function closeModals() { alert(1); if ($scope.warning) { $scope.warning.close(); $scope.warning = null; }
$scope.started = false;
function closeModals() {
alert(1);
if ($scope.warning) {
$scope.warning.close();
$scope.warning = null;
}
if ($scope.timedout) {
$scope.timedout.close();
$scope.timedout = null;
}
}
$scope.$on('IdleStart', function() {
closeModals();
$scope.warning = $modal.open({
templateUrl: 'warning-dialog.html',
windowClass: 'modal-warning'
});
});
$scope.$on('IdleEnd', function() {
closeModals();
});
$scope.$on('IdleTimeout', function() {
closeModals();
$scope.timedout = $modal.open({
templateUrl: 'timedout-dialog.html',
windowClass: 'modal-danger'
});
});
$scope.start = function() {
console.log('start');
closeModals();
Idle.watch();
$scope.started = true;
alert("Hi")
};
$scope.stop = function() {
console.log('stop');
closeModals();
Idle.unwatch();
$scope.started = false;
};
nuncasApp.config(function(IdleProvider, KeepaliveProvider) {
alert(3);
IdleProvider.idle(5);
IdleProvider.timeout(5);
KeepaliveProvider.interval(10);
IdleProvider.interrupt('keydown wheel mousedown touchstart touchmove scroll');
});
我从计算机上获取代码
我得到以下错误:
angular.js:13920 TypeError: Cannot read property 'watch' of undefined at b.$scope.start (loginCtrl.js:141)
at b.$scope.validateUser (loginCtrl.js:18)
at fn (eval at compile (angular.js:14817), <anonymous>:2:227) at b (angular.js:15906)
at e (angular.js:25885)
at b.$eval (angular.js:17682)
at b.$apply (angular.js:17782)
at HTMLButtonElement.<anonymous> (angular.js:25890)
at Sf (angular.js:3497)
at HTMLButtonElement.d (angular.js:3485)
angular.js:13920 TypeError:无法读取在b.$scope.start(loginCtrl.js:141)未定义的属性“watch”
在b.$scope.validateUser(loginCtrl.js:18)
在fn处(编译时求值(angular.js:14817),:2:227)在b处(angular.js:15906)
在e(angular.js:25885)
在b.$eval(angular.js:17682)
b.$apply(angular.js:17782)
在HTMLButtoneElement。(angular.js:25890)
在旧金山(angular.js:3497)
在HTMLButtonElement.d(angular.js:3485)
请确认您在var myApp=angular.module(“myApp”、['ngile'])
中正确注入了此依赖项,并在控制器中正确注入了app.controller('DemoCtrl',函数($scope,Idle/*other injections*/)
angular-idle.js中存在Watch方法。您是否在angular.module中注入了ngile依赖项?