使用 Angularjs 1.6.3,我有一个像这样的 Controller :
'use strict';
var ngnControllers = angular.module('ngnControllers');
ngnControllers.controller('TestCtrl', ['$scope', '$location', '$http',
function TestCtrl($scope, $location, $http) {
console.log("Before defining $scope.play()");
$scope.play() = function() {
};
console.log("After defining $scope.play()");
}
]);
我从另一个 Controller 复制了 $scope.play()
函数,它具有相同的效果:
当它没有被注释掉时,我收到一条消息说 Controller 没有注册,但仅此而已。当它被注释掉时,一切正常。
我很茫然。有什么想法吗?
最佳答案
因为您的函数声明语法错误,因此引发错误。该错误在内部被捕获并导致 Controller 注册失败
更改:
$scope.play() = function() {
至
$scope.play = function() {
关于javascript - 我有一个空函数,用于在 Angularjs 中注销我的 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45640013/