我以AngularJS開始,但無法獲得所需的輸出。這是代碼。無法獲取顯示的綁定值
的index.html
<!doctype html>
<html ng-app>
<head>
<script src="scripts/angular.min.js"></script>
<script src="scripts/underscore-min.js"></script>
<script type="text/javascript" src="scripts/todo.js"></script>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css">
</head>
<body>
<div ng-controller="TodoCtrl">
<h2>Total todos: {{totalTodos}}</h2>
<ul class="unstyled">
<li ng-repeat="todo in todos">
{{todo.text}}
</li>
</ul>
</div>
</body>
</html>
todo.js
function TodoCtrl($Scope) {
$Scope.totalTodos = 4;
$scope.todos = [
{ text: 'Learn AngularJS', done: false },
{ text: 'Build an appp', done: false }
];
}
這是我得到的輸出。 總計待辦事項:{{totalTodos}} –
您的代碼用於聲明控制器和應用程序模塊? –
如上所述,您需要var app = angular.module不太清楚我在移動設備上的代碼是什麼。 –