I have such a directive
ng-repeat="place in tb_places | filter:{'id':inputID}"
to output some array of objects it looks like this:
$scope.tb_places = [ {name: 'some1', id:1} ... {name: 'some10', id:10} {name: 'some11', id:11} {name: 'some12', id:12} ... ]
when I change the input identifier and set it to 1, the result array fills the elements of the original array with "identifiers" 1 and 10, 11, 12. Thus, part of the "id" value is checked as substrings, not numbers. How can I cure him?
thanks!
UPD I tried to add the expression ": true" in the filter expression - it completely clears the output (array of results), it works for a simple array of strings, but not for objects ("true" wants an exact match with the template object, this means that all of it properties)
SOLVE!!!
Sorry guys, I'm to blame! "inputID" was not the same type as "id" (string vs int), so the built-in comparator (": true") returns false. Many thanks!
ps sorry, I can not vote for you answers - lack of reputation ... see you!
arrays angularjs angularjs-filter angularjs-ng-repeat
georgiy.zhuravlev
source share