简体   繁体   English

AngularJs ng-repeat遍历2个数组

[英]AngularJs ng-repeat looping through 2 arrays

I am trying to achieve this view by looping through 2 arrays 我试图通过遍历2个数组来实现此视图 在此处输入图片说明

but from the ng-repeats that I'm using, I get this view 但是从我正在使用的ng-repeats中,我得到了这个视图

在此处输入图片说明

This is the code that I have right now 这是我现在拥有的代码

$scope.properties = ["First name", "Last name"];

$scope.labels = ["john", "doe"];

//jade
.col-md-12
    .col-md-6(ng-repeat="property in properties")
        label {{ property }}
    .col-md-6(ng-repeat="label in labels")
            {{ label }}

Try this Use $index it will give the current index in properties array 试试这个使用$index它将在属性数组中给出当前索引

HTML 的HTML

 <div ng-repeat="prop in properties" class="col-md-12">
    <div class="col-md-6">
      <label>{{prop}}</label>
    </div>
    <div class="col-md-6">
      <label>{{labels[$index]}}</label>
    </div>
  </div>

JADE

.col-md-12(ng-repeat='prop in properties')
  .col-md-6
    label {{prop}}
  .col-md-6
    label {{labels[$index]}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM