我怎么能回到几个名字:[苹果,橘子,胡萝卜] [http://jsfiddle.net/GruffBunny/QHtD8/2/] 1
function MyCtrl($scope) {
$scope.products = [
{id:"1",type:"fruit"},
{id:"2",type:"meat"},
{id:"3",type:"drink"},
{id:"4",type:"vegetable"},
{id:"5",type:"dairy"}
];
$scope.fruitOrVeg = function(product){
return product.name == ['1','4','5'];
};
非常感谢
答案 0 :(得分:0)
更改模板,调用功能:
System.out.print
和过滤功能,返回新功能
<li ng-repeat="item in products | filter:fruitOrVeg()">{{item.name}}</li>
};
添加了JSFiddler
答案 1 :(得分:0)
app.filter('filterByFruitOrVeg', function() {
return function(array) {
arr = arr.filter(payment, function(objectInArray) {
return objectInArray.type === 'fruit' || objectInArray.type === 'vegetable';
});
}
});