爲什麼我的控制器執行兩次?AngularJs基本應用程序執行兩次
我做了很多測試,它返回相同的結果,它可以影響我的應用程序?
<html ng-app="todoApp">
<head>
\t <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
\t <script>
\t "use strict";
angular.module('todoApp', [])
.controller('TodoListController', function() {
var todoList = this;
\t \t var i = 0;
todoList.addTodo = function() {
console.log(1)
\t \t \t i++;
\t \t \t // return i it breaks the script
};
});
\t </script>
</head>
<body ng-controller="TodoListController as todoList">
\t {{todoList.addTodo()}}
</body>
</html>