Angularjs Angular.js过滤器,用于显示JSON数据中的相同值
这是我的代码,我试图呈现一个项目列表,其中应该包含“type_transaction”等于“paypal”,我试图避免呈现不同于“paypal” JSON格式的数据:Angularjs Angular.js过滤器,用于显示JSON数据中的相同值,angularjs,Angularjs,这是我的代码,我试图呈现一个项目列表,其中应该包含“type_transaction”等于“paypal”,我试图避免呈现不同于“paypal” JSON格式的数据: { "orders":[ { "id_order":"374", "type_transaction":"paypal" }, { "id_
{
"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:
它给了我一个错误,它显示了ReferenceError:赋值中的左侧无效
我仍然不明白$filter是如何工作的。试着用引号括住字符串(paypal):
ng if=“order.type_transaction=='paypal'”在html中尝试使用ng ifview@amani92你能详细说明一下吗?我尝试将ng if=“'type_transaction':'paypal'”与ng repeat放在一起,这样它就不能工作
$filter('filter')(…)=data.orders代码>您的错误不是关于$filter
——而是javascript的工作方式。
<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>
$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;
});
}