app. filter('bygenre', function() {
var out = [];
return function(phone , genres) {
if(genres) {
angular.forEach(phone, function (value, key) {
console.log(value.rating);
console.log(Number(genres.rating))
if (value.rating & genres.rating){
if (value.rating == Number (genres.rating))
{
//alert("hello");
console.log("this is value"+ JSON.stringify (value));
out.push[value];
console.log("this is out"+ JSON.stringify (out));
}
}
});
}
console.log("this is "+ JSON.stringify (out));
return out ;
}
});
我有这个代码out.push [value];不适合我 http://plnkr.co/edit/8ArGO1OvT7FHIV1ixSEA?p=preview Plunker link
答案 0 :(得分:2)
数组推送是一种方法,所以:
out.push[value]
应为out.push(value)
。