Search code examples
angularjsangular-filters

$filter not finding result because of data type


In JSON i have data like

"phaseId":1234

and i have written code like

$filter('filter')(data, {phaseId: phaseId.toString()},true) this finds results.

but below code does not find. Is there any specific reason for this?

$filter('filter')(data, {phaseId: phaseId},true)

1234 is of type number and phaseId passed is also number


Solution

  • Remove the last parameter true (which means strict comparison, will assert that type and value are equals):

    $filter('filter')(data, {phaseId: phaseId});