我正在努力让阵列显示出我想要的样子。
我有:
$scope.array = [["one", "two", "three", "four"], "five"],["six", "seven", "three", "four"], "two"]];
我想迭代并显示第一个数组中的字符串。我想展示:
一二三四 六七三四。目前我有以下内容:
<p ng-repeat="a in array">{{a[0]}}</p>
但它出现了:
["one", "two", "three", "four"]
["six", "seven", "three", "four"]
我已经尝试了一个过滤器来删除引号等,但它不断拉起另一个数组。
答案 0 :(得分:6)
试试这个
<div ng-repeat="item in array">
<div ng-repeat="a in item[0]">
{{a}}
</div>
</div>
,数组应该是这样的
$scope.array =
[
[["one", "two", "three", "four"], "five"],
[["six", "seven", "three", "four"], "two"]
];
var app = angular.module('app', []);
app.controller('main', ['$scope', function($scope) {
$scope.array = [
[
["one", "two", "three", "four"], "five"
],
[
["six", "seven", "three", "four"], "two"
]
];
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller=main>
<div ng-repeat="item in array">
<div ng-repeat="a in item[0]">
{{a}}
</div>
</div>
</div>