我尝试以角度重复多层数组,但可能使用的方法不正确,这就是示例:
var app = angular.module("app", []);
app.controller("index", ["$scope", function ($scope) {
$scope.list = [
{
list2: ["1111"]
},
{
list2: ["2222"]
},
{
list2: ["3333"]
}
];
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="index">
<ul ng-repeat="l in list">
<li ng-repeat="item in l.list2">
<input type="text" ng-model="item" style="width: 300px;"/>
</li>
</ul>
<pre>{{list |json}}</pre>
</div>
答案 0 :(得分:0)
您使用的也是正确的。 您可以使用以下实现来简化它。
var app = angular.module("app", []);
app.controller("index", ["$scope", function ($scope) {
$scope.list = [
["1111"],["2222"],["3333"]
];
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="index">
<ul ng-repeat="l in list">
<li ng-repeat="item in l">
<input type="text" ng-model="item" style="width: 300px;"/>
</li>
</ul>
<pre>{{list |json}}</pre>
</div>