Multiple filter in ng-repeat -
i need filtering data in ng-repeat. i've tried few things can't find solution works in case. need to this:
sensor in sensors | filter: { group: group.id, (name: search || description: search) }
search ng-model
(text input) , group.id
id of group genereted in ng-repeat
(i have 2 nested ng-repeat). i've tried filter:
$scope.search = ''; $scope.searchfilter = function() { return function (p) { if ($scope.search!='') { (var in p) { console.log("p.name: "+p.name+", search: "+$scope.search); if (p.name == $scope.search || p.description == $scope.search) { return p; } } } else { return p; } } }
almost works. filters data if write correct name. example want find "engine". if start writing "en" there no data if write "engine" display correct data. need work on too. hope understand want do.
i've found solution!
sensor in sensors filter: { group: group.id } | filter: searchfilter()
and this:
$scope.search = ''; $scope.searchfilter = function() { return function (p) { if ($scope.search!='') { (var in p) { var re = new regexp($scope.search, 'i'); // i've add if (p.name.match(re) || p.description.match(re) ) { // i've change return true; } } } else { return true; } } }
Comments
Post a Comment