1

I have an array of objects like mentioned below.

$scope.paymentArray= [
    { id: 10 ,paymentMode: 'Cash',  amount:100},
    { id: 11 , paymentMode: 'Debit Card', amount:200},
    { id:12, paymentMode: 'Cash',amount: 900 },
    { id: 13, paymentMode: 'Credit Card', amount:500},
    { id:14,paymentMode: 'Cash', amount: 600 }
];

When I run a ng-repeat on this

<div ng-repeat ="payment in paymentArray">
<span>{{$index+1}}</span>)<span>Mode : {{payment.paymentMode}}</span><span>Amount : {{payment.amount}}</span>
</div>

I get the result as such:
1)Mode:Cash Amount:100
2)Mode:Debit Card Amount:200
3)Mode:Cash Amount:900
4)Mode:Credit Card Amount:500
5)Mode:Cash Amount:600

But I need to club the data with same payment mode as one and represent the result in the following manner.

1)Mode:Cash Amount:100
            Amount:600
            Amount:900
2)Mode:Debit Card Amount:200
3)Mode:Credit Card Amount:500

Please help.Thanks in advance.

Shijil Narayanan
  • 1,011
  • 8
  • 21

0 Answers0