如何在filter
函数中的匿名函数中访问searchStr变量?在searchStr下面打印0 - n,我猜一个循环遍历我试图过滤的集合的迭代器
IEG.vent.on("searchGroups", function (searchStr) {
if (searchStr) {
IEG.Router.navigate("search/" + searchStr);
}
else {
IEG.Router.navigate();
}
var filteredArray = IEG.searchColl.models.filter(function (model,searchStr) {
console.log(model.get("key") + searchStr)
});
});
答案 0 :(得分:4)
从searchStr
功能的参数中删除filter
:
var filteredArray = IEG.searchColl.models.filter(function (model) {
console.log(model.get("key") + searchStr);
});