Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49084

Can I use ng-repeat twice on the same object $scope variable?

$
0
0

@shreyasgombi wrote:

Hi guys,
A newbie here. Let's say I have an object like this in a controller,

In Controller :
var $scope.orders = [{"id": "1", "code":"AAA", "type":"orders", "product":"Cookies"},
{"id": "2", "code":"AAA", "type":"orders", "product":"Cream"},
{"id": "3", "code":"BBB", "type":"orders", "product":"Pie"},
{"id": "4", "code":"AAA", "type":"orders", "product":"Nutella"}]

In HTML View :
Can I use two ng-repeat on this $scope.orders like this,

<div ng-repeat="order in orders" ng-if="order.code=='AAA'">
Order Type : {{order.type}}, Product : {{order.product}}
</div>

<div ng-repeat="order in orders" ng-if="order.code=='BBB'">
Order Type : {{order.type}}, Product : {{order.product}}
</div>

I am getting an output though I see the orders with code BBB is also showing in the list of AAA, and sometimes AAA orders don't show up. Is this a valid way to do? Any input would be great. :smile:

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49084

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>