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

javascript - Display the group values using angular js..?

问题描述:

Now I have created a script like this.

$scope.newsample = {

1 : [

{'SUPNAME' : 'HABIB','PKSLIP' : '17193','PRDCODE' : '52003','ITMDESG' : '2550','ITMCODE' : 'IAC1552072','iv' : '1'},

],

2 : [

{'SUPNAME' : 'EKJOT','PKSLIP' : '55414','PRDCODE' : '52236','ITMDESG' : '420','ITMCODE' : 'IBD5243688','iv' : '2'},

{'SUPNAME' : 'EKJOT','PKSLIP' : '55414','PRDCODE' : '52236','ITMDESG' : '426','ITMCODE' : 'IBD5243661','iv' : '3'},

{'SUPNAME' : 'EKJOT ','PKSLIP' : '55414','PRDCODE' : '52236','ITMDESG' : '428','ITMCODE' : 'IBD5243709','iv' : '4'},

],

3 : [

{'SUPNAME' : 'JAYSONS','PKSLIP' : '50225','PRDCODE' : '53554','ITMDESG' : '6089','ITMCODE' : 'IBC4745296','iv' : '5'},

]

}

$scope.total = [

{'iv' : '1'},

{'iv' : '2'},

{'iv' : '3'},

]

Now how can I display it in this format.

SUPNAME:HABIB PKSLIP:17193

ITMDESG:IAC1552072

SUPNAME:EKJOT PKSLIP=55414

ITMDESG:IBD5243688 ITMDESG:IBD5243661 ITMDESG3:IBC4745296

SUPNAME:JAYSONS PKSLIP:50225

ITMDESG:IBC4745296

I have tryed like this,but SUPNAME is also repeating give some idea that how can I use ng-if to skip the same SUPNAME. I need to display the SUPNAME once and corresponding ITMDESG should be displayed in grouped format.

<div ng-repeat="tot_grp in total " ng-init="subval=newsample[tot_grp.iv]">

<div ng-repeat = "grp_val in subval">

<div>

<label>{{{{grp_val.SUPNAME}}}}</label>

<label>{{{{grp_val.PKSLIP}}}}</label>

</div>

<div style="clear:both"></div>

<div>

<label>{{{{grp_val.ITMDESG}}}}</label>

</div>

</div>

</div>

网友答案:

You could use $first for inner ng-repeat

Markup

<div ng-repeat = "grp_val in subval">
    <div ng-if="$first">
      <label>{{grp_val.SUPNAME}}</label>
      <label>{{grp_val.PKSLIP}}</label>
    </div>
    <div style="clear:both"></div>
    <div>
    <label>{{grp_val.ITMDESG}}</label>
    </div>
</div>
分享给朋友:
您可能感兴趣的文章:
随机阅读: