Pravin
Pravin

Reputation: 441

How to group and display the values in angular js

I have created a scope function like this

$scope.sample = [
   {'SUPNAME':'AAA','SUPCODE':'22671','SLIPNO':'18384','DESG':'1','iv':'1'},
   {'SUPNAME':'AAA','SUPCODE':'22671','SLIPNO':'18384','DESG':'2','iv':'2'},
   {'SUPNAME':'AAA','SUPCODE':'22671','SLIPNO':'18384','DESG':'3','iv':'3'},
   {'SUPNAME':'BBB','SUPCODE':'24603','SLIPNO':'26714','DESG':'1','iv':'4'},
   {'SUPNAME':'BBB','SUPCODE':'24603','SLIPNO':'26714','DESG':'2','iv':'5'},
   {'SUPNAME':'BBB','SUPCODE':'24603','SLIPNO':'26714','DESG':'3','iv':'6'},
]

I have to display by grouping with same SUPNAME,SUPCODE,SLIPNO. For example I have to display it like this.

SUPNAME:AAA  SUPCODE=22671
DESG 1  DESG2 DESG 3


SUPNAME:BBB   SUPCODE=24603
DESG 1  DESG2 DESG 3

So how can I create ng-repeat for this..Kindly give some solution.

Upvotes: 0

Views: 92

Answers (1)

stackg91
stackg91

Reputation: 594

i tried to create a Codepen for your case

grouped Codepen

<table  class="table table-striped">
<tr><td>{{data1}}</td><td>{{data2}}</td></tr>
<tr ng-repeat="item in filteredsample = (sample | filter:{ SUPNAME: 'AAA'})">
</tr>
  <ul ng-repeat="thing in filteredsample">
<li style = "float:left; margin:20px">DESG VALUE {{$index}} = {{thing.DESG}}</li>
</ul>
</div>

Hope this helps

Upvotes: 2

Related Questions