AngularJS ng-repeat示例不起作用
AngularJS ng-repeat example not working
我目前正在尝试从AngularJS书中尝试一个例子,但它不起作用。我在巴塔朗得到一个错误说:
ype错误:无法读取未定义的属性"#"
这是 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
后错过了=
用
$scope.countries = [
{name: 'France', population: 63.1},
{name: 'United Kingdom', population: 61.8}
];
工作演示
你忘记了=
$scope.countries = [ {name: 'France', population: 63.1}, {name: 'United Kingdom', population: 61.8} ];
看这里:
http://jsfiddle.net/konan/xaAxs/
function ctrl($scope) {
$scope.population = 7000;
$scope.countries = [
{name: 'France', population: 63.1},
{name: 'United Kingdom', population: 61.8}
];
};
相关文章:
- Angular js+ng repeat+字母数字索引不起作用
- 尝试使用 AngularJS ng-repeat 显示 JSON 数据不起作用
- 我不知道为什么ng repeat在我的代码中不起作用
- 角度指令作用域绑定在 ng-repeat中不起作用
- AngularJS ng-repeat在更新时不起作用
- AngularJS ng-repeat示例不起作用
- 嵌套的 ng-repeat 在<输入>中不起作用
- AngularJS ng-repeat在Django驱动的网页上不起作用
- Md-switch在ng-repeat中不起作用
- Angular js ng-repeat和ng-show在刷新时不起作用
- ng-repeat中的角度文件输入(引导)不起作用
- 尽管使用了最新的 angularJS 版本,但 ng-repeat-start 不起作用的任何原因
- Angular ng-repeat中的Json字符串不起作用
- 使用Angular ng-repeat将数据动态加载到materializecss滑块中不起作用
- AngularJS:ng-repeat不起作用
- 尝试输出多维数组时,AngularJS中的ng repeat不起作用
- 在Angularjs应用程序中,使用嵌套对象属性过滤ng repeat不起作用
- order by and click在ng repeat angular js中不起作用
- 使用Angular ng repeat指令进行重复时,复选框不起作用
- ng repeat在引导模式下不起作用