Reputation: 837
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:
I want to see a result like this:
Upvotes: 0
Views: 1037
Reputation: 393
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>
Upvotes: 1