我目前在尝试一本AngularJS书中的示例,但它并没有正常工作。
在Batarang中出现了一个错误:
TypeError: Cannot read property '#' of undefined
这是HTML代码:
<body ng-app>
<h1>Countries</h1>
<ul ng-controller="WorldCtrl">
<li ng-repeat="country in countries">
{{country.name}} has population of {{country.population}}
</li>
<hr>
World's population: {{population}} millions
</ul>
</body>
我的JS
var WorldCtrl = function ($scope) {
$scope.population = 7000;
$scope.countries [
{name: 'France', population: 63.1},
{name: 'United Kingdom', population: 61.8}
];
};
有什么想法是为什么这不起作用? 谢谢。
=
$scope.countries = [ {name: '法国', population: 63.1}, {name: '英国', population: 61.8} ];
- Stephane Rolland