I am having trouble sorting and displaying data with AngularJS. I have added a sort option to my table, but it does not seem to be working properly.
Could you please review my JSON data?
[
{
"id":143,
"companyName":"XC",
"dividendIncome":66666666,
"warrantNo":"777777",
"taxExempt":0,
"status":"ACTIVE",
"periodId":{
"periodId":4,
"period":"2020-2021",
"startDate":"2020-04-01",
"endDate":"2021-03-31",
"status":null
},
"userId":2,
"isSpecialCategory":false,
"isDivDistributByInvestee":false,
"isDivPaidOutExemptProfits":false,
"dividendIncomeReceivedDate":"2020-05-12"
},
{
"id":145,
"companyName":"ghhh",
"dividendIncome":6700000,
"warrantNo":"555634",
"taxExempt":0,
"status":"ACTIVE",
"periodId":{
"periodId":4,
"period":"2020-2021",
"startDate":"2020-04-01",
"endDate":"2021-03-31",
"status":null
},
"userId":2,
"isSpecialCategory":false,
"isDivDistributByInvestee":false,
"isDivPaidOutExemptProfits":false,
"dividendIncomeReceivedDate":"2020-05-11"
}
]
I have created an HTML table to display this data, and everything seems to be showing correctly. Here is the 'ng-repeat' section for your reference:
<tr ng-repeat="dividendIncome in dividendIncomeList | orderBy:'-id'">
<td>{{dividendIncome.id}}</td>
<td>{{dividendIncome.companyName}}</td>
<td>{{dividendIncome.warrantNo}}</td>
<td align="right">{{dividendIncome.dividendIncome | number:2}}</td>
<td align="right">{{dividendIncome.taxExempt| number:2}}</td>
</tr>
As per my requirements, I need id:145 to be displayed first followed by id:143. Are there any issues in my code? Can you assist me in fixing this problem?