index.html is:
獲得 「未捕獲的ReferenceError:updateClock沒有定義」 的錯誤在AngularJS應用
<html ng-app="clock">
<head>
<script type="text/javascript" src="angular.js"></script>
<script type="text/javascript" src="app.js"></script>
</head>
<body>
<h1 ng-controller="ClockController">{{clockTime}}</h1>
</body>
</html>
And app.js is:
var app = new angular.module('clock',[]);
(function(){
app.controller('ClockController',function($scope){
this.updateClock = function(){
$scope.clockTime = new Date();
};
setInterval(function(){
$scope.$apply(updateClock);
},1000);
this.updateClock();
});
})();
當我訪問index.html
我一直在1秒鐘後收到以下錯誤。
Uncaught ReferenceError: updateClock is not defined
我已經定義updateClock
setInterval
之前被稱爲仍然爲什麼我得到這個消息?
你指的是什麼「父功能」? – user4904589
它是控制器的功能 – udalmik