Please dont edit the english for this question because I wont be able to approve the suggestions and this question wont get resolved.
请不要编辑这个问题的英语,因为我无法批准这些建议,这个问题不会得到解决。
In the above picture it shows the currently displayed content. But I want to display plan names on the left of the ids
在上图中,它显示了当前显示的内容。但我想在ID的左侧显示计划名称
something like this
这样的事情
plan_abc 109426 btn btn
plan_def 109428 btn btn
plan_ghi 109423 btn btn
plan_abc 109426 btn btn plan_def 109428 btn btn plan_ghi 109423 btn btn
json format is as below
json格式如下
Code used:
<ul class="ul-plan">
<li class="no-bullet-li li-8 monaco" ng-repeat="item in plan.planIds">
{{item}}
<a ng-click="select('one')" href=""><i class="glyphicon glyphicon-pencil iconing"></i></a>
<a ng-click="deleteClick(item)" href=""><i class="glyphicon glyphicon-remove iconing_1"></i></a>
</li>
first try
<li class="no-bullet-li li-8 monaco" ng-repeat="item in plan.planIds" "name in plan.planNames">
{{name}} {{item}}
</li>
2 个解决方案
#1
1
If you have two collections with the same size, lets say:
如果您有两个大小相同的集合,请说:
$scope.data = { planIds: [1, 2, 3, 4], planNames: ['a', 'b', 'c', 'd'] }
You can use $index
:
你可以使用$ index:
<div ng-repeat="id in data.planIds">
{{ id }} - {{ data.planNames[$index] }}
</div>
#2
1
If you can change the json-structure, then it's more logical to have it on object form:
如果你可以改变json结构,那么将它放在对象形式上更合乎逻辑:
plans: [{
id: 1098565,
name: 'plan_abc'
},...]
If you can't change the json, and the two arrays always have the same length:
如果无法更改json,则两个数组的长度始终相同:
<li class="no-bullet-li li-8 monaco" ng-repeat="item in plan.planIds">
{{item}} {{plan.planNames[$index]}}
</li>
$index is a magic value that comes from the ng-repeat directive. As you probably can guess, it keeps track of the where you are in the repeater.
$ index是来自ng-repeat指令的神奇值。正如您可能猜到的那样,它会跟踪您在转发器中的位置。
#1
1
If you have two collections with the same size, lets say:
如果您有两个大小相同的集合,请说:
$scope.data = { planIds: [1, 2, 3, 4], planNames: ['a', 'b', 'c', 'd'] }
You can use $index
:
你可以使用$ index:
<div ng-repeat="id in data.planIds">
{{ id }} - {{ data.planNames[$index] }}
</div>
#2
1
If you can change the json-structure, then it's more logical to have it on object form:
如果你可以改变json结构,那么将它放在对象形式上更合乎逻辑:
plans: [{
id: 1098565,
name: 'plan_abc'
},...]
If you can't change the json, and the two arrays always have the same length:
如果无法更改json,则两个数组的长度始终相同:
<li class="no-bullet-li li-8 monaco" ng-repeat="item in plan.planIds">
{{item}} {{plan.planNames[$index]}}
</li>
$index is a magic value that comes from the ng-repeat directive. As you probably can guess, it keeps track of the where you are in the repeater.
$ index是来自ng-repeat指令的神奇值。正如您可能猜到的那样,它会跟踪您在转发器中的位置。