好的,试着做我应该做的简单的事情,我需要使用ng-重复和连接数组。完全不明白为什么这不管用。它非常适合基于数字的数组键,但不适合文本字符。
function HelloCntl($scope) {
$scope.friends = [];
$scope.friends[0] ='John',
$scope.friends[1]= 'Mary',
$scope.friends['aksnd']= 'Mike',
$scope.friends['alncjd']= 'Adam',
$scope.friends['skdnc']= 'Julie'
}
----
<div ng-controller="HelloCntl">
<ul>
<li ng-repeat="friend in friends">
<span>{{friend}}</span>
</li>
</ul>
</div>我还把这把小提琴放在一起来显示发生了什么,http://jsfiddle.net/b9g0x7cw/4/
我在这里做错什么了?我漏掉了什么明显的东西吗?
谢谢你们!
发布于 2014-11-06 14:15:58
在JavaScript中,我们没有关联数组--我们有对象:
更新小提琴:http://jsfiddle.net/edut808r/
angular.module('MyApp', []).filter('removeAdam', function() {
})
.controller('HelloCntl', function($scope) {
$scope.friends = {
asdf:'John',
dkfls: 'Mary',
aksnd: 'Mike',
alncjd: 'Adam',
skdnc: 'Julie'
}
});https://stackoverflow.com/questions/26781498
复制相似问题