Reputation: 1241
This is my code, I'm trying to render a list of items should contain "type_transaction" is equal to "paypal" and im trying to avoid rendering different than "paypal".
DATA in JSON:
{
"orders":[
{
"id_order":"374",
"type_transaction":"paypal"
},
{
"id_order":"373",
"type_transaction":"credit-card"
},
{
"id_order":"372",
"type_transaction":"credit-card"
},
{
"id_order":"371",
"type_transaction":"paypal"
}
]
}
HTML:
<tbody ng-init="get_orders()">
<tr ng-repeat="order in orders | filter:searchText">
<td>{{order.id_order}}</td>
<td>{{order.type_transaction}}</td>
</tr>
</tbody>
Javascript function will apply the filter to display a list according if their items are same to "Paypal":
$scope.get_orders = function(n) {
$http.post(url, $scope.main ).success(function(data){
$filter('filter')(data.orders, "'type_transaction': 'paypal'", true) = data.orders;
//$scope.orders = data.orders;
});
}
It gave me an error, it showed ReferenceError: Invalid left-hand side in assignment I still don't understand how $filter works.
Upvotes: 1
Views: 38
Reputation: 913
Try to surround string (paypal) with quotes ':
ng-if="order.type_transaction=='paypal'"
Upvotes: 1