当前位置: 动力学知识库 > 问答 > 编程问答 >

Display data with an AngularJS ng-repeat, in a div, side by side

问题描述:

I have an arraylist from which I need to get values where isActive = true, and to display the data in a <div> tag with the use of ng-repeat.

My problem is that I don't want to keep using ng-repeat every time, while fetching values in each <div> tag.

Is there any generic solution which will iterate only once, and I can see the value in <div>, side by side. Please see this attempt:

enter link description here

I want to see a result like this:

网友答案:

You can write your ng-repeat like below. Whenever it get isActive true, it will create the div section for this.

<body ng-controller="MainCtrl">
    <div ng-repeat="tempData in data">
      <div ng-if="tempData.isActive == true" >
        <div class="col-xs-12" >
            <div class="col-xs-4">Plan Type:</div>
            <div class="col-xs-8">{{tempData.plantype}}</div>
        </div>
        <div class="col-xs-12">
            <div class="col-xs-4">Term:</div>
            <div class="col-xs-8">{{tempData.term}}</div>
        </div>
        <div class="col-xs-12">
            <div class="col-xs-4">Rate:</div> 
            <div class="col-xs-8">{{tempData.rate}}</div>
        </div>
      </div>

    </div>

  </body>
分享给朋友:
您可能感兴趣的文章:
随机阅读: