chap1->Observables to refresh the UI automatically->Computed observables (optimised)

chap2
jason.zhu 2021-05-27 04:43:27 +00:00
parent 48d61e59b9
commit 834316a5a4
1 changed files with 2 additions and 10 deletions

View File

@ -35,16 +35,8 @@ var vm = (function () {
} }
//filter data //filter data
var filtered = ko.utils.arrayFilter(catalog(), function (item) { var filtered = ko.utils.arrayFilter(catalog(), function (item) {
var fields = ["name"]; // we choose to filter by name var strProp = ko.unwrap(item["name"]).toLocaleLowerCase();
var i = fields.length; return (strProp.indexOf(filter) > -1);
while (i--) {
var prop = fields[i];
var strProp = ko.unwrap(item[prop]).toLocaleLowerCase();
if (strProp.indexOf(filter) !== -1) {
return true;
}
}
return false;
}); });
return filtered; return filtered;
}); });