1
我有以下的標記......AngularJS NG-控制器聲明
<!DOCTYPE html>
<html lang="en-US" ng-app>
<head>
<title>priklad00007</title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script src="priklad00007.js"></script>
</head>
<body ng-controller="MyFirstCtrl">
<h2>Number of employees: {{ourEmployees.length}}</h2>
</body>
</html>
用下面的JavaScript ...
function MyFirstCtrl($scope) {
var employees = ["Karel Novak", "Martin Cervenka", "Jana Zelena", "Frantisek Vomacka"];
$scope.ourEmployees = employees;
}
我希望得到
員工人數:4
但我不是得到
員工人數:{{ourEmployees.length}}
可能是什麼回事?
必須添加你的函數MyFirstCtrl到你的angular.module –