I've the following structure.
[
{
"Variants": [
{
"SellPrice": "75.00",
"VariantID": "10",
"VariantName": "1 L",
"InCart": "2",
"MRP": "115.00",
"VariantImagePath": "/images/ruchi/710_10.png"
},
{
"SellPrice": "410.00",
"VariantID": "113",
"VariantName": "5 L",
"InCart": "1",
"MRP": "485.00",
"VariantImagePath": "/images/ruchi/710_113.png"
},
{
"SellPrice": "1080.00",
"VariantID": "219",
"VariantName": "15L - Jar",
"InCart": "0",
"MRP": "1275.00",
"VariantImagePath": "/images/ruchi/710_219.png"
}
],
"SubCategoryID": "32",
"ProductImagePath": "/images/ruchi/710.png",
"SubCategoryName": "Soyabean Oil",
"BrandName": "Ruchi",
"ProductID": "710",
"BrandID": "117",
"ProductName": "Ruchi soya oil"
},
{
"Variants": [
{
"SellPrice": "58.00",
"VariantID": "23",
"VariantName": "900 GM",
"InCart": "1",
"MRP": "60.00",
"VariantImagePath": "/images/mtr/771_23.png"
}
],
"SubCategoryID": "110",
"ProductImagePath": "/images/mtr/771.png",
"SubCategoryName": "Vermicelli",
"BrandName": "MTR",
"ProductID": "771",
"BrandID": "167",
"ProductName": "Seviyan Vermicelli"
}
]
Want to filter all the data where Variants.InCart value is > 0.
In this case output will be
ProductID VariantID InCart
710 113 1
710 10 2
771 23 1
and this is my loop.
<tr ng-repeat="Item in ProductService.Products | <what should be filter condition here>">
<td>{{Item.ProductID}} {{Item.Variants.VariantID}} {{Item.Variants.InCart}}</td>
</tr>
Please help.
<tr ng-repeat="Item in ProductService.Products | filter:customArrayFilter">
<td>{{Item.ProductID}} {{Item.Variants.VariantID}} {{Item.Variants.InCart}}</td>
</tr>
$scope.customArrayFilter = function (item) {
return (item.InCart > 0);
};
You can add custom filter like this..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.