Currently, I am utilizing Angular's ng-repeat
along with groupBy
and orderBy
. My goal is to sort by SeatNo ascendingly as in 1, 2, 8, 12 but Angular seems to be giving me 1, 12, 2, 8 instead.
Note: I am aware that SeatNo is a string and have attempted using parseInt
without success.
Here is the HTML:
<tbody ng-if="::!isOnlyAllSeat" ng-repeat="(key, value) in billRaw | groupBy: 'SeatNo' | orderBy: 'SeatNo' track by key">
<tr class="right bg-darkBlue fg-white">
<td colspan="{{::colSpan}}"> Seat {{key==0?"ALL":key}}</td>
<td class="right bill-col-5"><span class="label bg-white fg-black place-right">{{value.length}}</span></td>
</tr>
<tr ng-repeat="item in value | orderBy: 'ClassCode' " class="fg-darkBlue">
<td class="bill-col-1 middle">{{ item.ClassCode }}</td>
<td class="text-left bill-col-2 middle">
<span class="">{{ item.Name }}</span>
<div class="note-tag-list" ng-if="item.Options">
<div class="note-tag-item note-tag" ng-repeat="question in item.Options track by question.Question_ID">
<div ng-repeat="option in question.Options track by option.Option_ID">
<a href class="label info note-tag">{{ option.Option }}
<small class="price-tag" ng-if="option.ActualPrice !== '0.00'">+{{option.ActualPrice | currency}}</small>
</a>
</div>
</div>
</div>
</td>
<td class="text-left bill-col-5 middle">
<div>{{ item.ActualPrice | currency }}</div>
<div><small ng-if="item.OptionsTotalActualPrice !== 0">+{{ item.OptionsTotalActualPrice | currency }} : Add-on </small></div>
<div ng-if="item.DiscountAmt>0"><span class="fg-red">({{ (getDiscount(item) | currency) }})</span> : {{ ((item.ActionTypeID == 1) ? item.DiscountAmt+'% OFF':item.CodeName) }}</div>
<div ng-if="item.ActionTypeID == 1">{{ item.CodeName }}</div>
</td>
</tr>
</tbody>
This is my billRaw
array.
Please note that it is currently sorted by SeatNo:
[
{"OrderItemID": "329277",
"Name": "Mexican Tacos",
"Delivered": "0",
"ShortName": "MEXICAN TACOS",
"Price": "8.0000",
"MenuItemID": "2318",
"SeatNo": "1",
"SequenceNo": "37",
"AlcoholCheck": "0",
"OStatusID": "2",
"Notes": "",
"Options": [],
"OptionsTotal": 0,
"OptionsTotalActualPrice": 0,
"ActualPrice": "8.00",
"CodeID": 0,
"DiscountAmt": 0,
"ActionTypeID": 0,
"CodeName": 0,
"ReductionType": 0,
"PayerSeq": "0",
"PriceType_ID": "1",
"ParentClassName": "Tacos",
"NetPrice": 8,
"ExtItem_ID": "J9X79NS28M1ZY",
"ExtOrderItem_ID": null,
"Code": null
},
{
"OrderItemID": "329278",
"Name": "Mexican Tacos",
"Delivered": "0",
"ShortName": "MEXICAN TACOS",
"Price": "8.0000",
"MenuItemID": "2318",
"SeatNo": "2",
"SequenceNo": "38",
"AlcoholCheck": "0",
"OStatusID": "2",
"Notes": "",
"Options": [],
"OptionsTotal": 0,
"OptionsTotalActualPrice": 0,
"ActualPrice": "8.00",
"CodeID": 0,
"DiscountAmt": 0,
"ActionTypeID": 0,
"CodeName": 0,
"ReductionType": 0,
"PayerSeq": "0",
"PriceType_ID": "1",
"ParentClassName": "Tacos",
"NetPrice": 8,
"ExtItem_ID": "J9X79NS28M1ZY",
"ExtOrderItem_ID": null,
"Code": null
},
{
"OrderItemID": "329276",
"Name": "Mexican Tacos",
"Delivered": "0",
"ShortName": "MEXICAN TACOS",
"Price": "8.0000",
"MenuItemID": "2318",
"SeatNo": "8",
"SequenceNo": "36",
"AlcoholCheck": "0",
"OStatusID": "2",
"Notes": "",
"Options": [],
"OptionsTotal": 0,
"OptionsTotalActualPrice": 0,
"ActualPrice": "8.00",
"CodeID": 0,
"DiscountAmt": 0,
"ActionTypeID": 0,
"CodeName": 0,
"ReductionType": 0,
"PayerSeq": "0",
"PriceType_ID": "1",
"ParentClassName": "Tacos",
"NetPrice": 8,
"ExtItem_ID": "J9X79NS28M1ZY",
"ExtOrderItem_ID": null,
"Code": null
},
{
"OrderItemID": "329275",
"Name": "Mexican Tacos",
"Delivered": "0",
"ShortName": "MEXICAN TACOS",
"Price": "8.0000",
"MenuItemID": "2318",
"SeatNo": "12",
"SequenceNo": "35",
"AlcoholCheck": "0",
"OStatusID": "2",
"Notes": "",
"Options": [],
"OptionsTotal": 0,
"OptionsTotalActualPrice": 0,
"ActualPrice": "8.00",
"CodeID": 0,
"DiscountAmt": 0,
"ActionTypeID": 0,
"CodeName": 0,
"ReductionType": 0,
"PayerSeq": "0",
"PriceType_ID": "1",
"ParentClassName": "Tacos",
"NetPrice": 8,
"ExtItem_ID": "J9X79NS28M1ZY",
"ExtOrderItem_ID": null,
"Code": null
}
]
Edit
I have adjusted billRaw so that the type
of SeatNo is now number
, however, the issue still persists.
_.forEach($scope.billRaw, function(value,key) {
value.SeatNo = parseInt(value.SeatNo);
});