Paolo B Paolo B - 6 months ago 18
AngularJS Question

ng-true-value='0' picking up wrong values

For demo see jsfiddle here and click on the

Out of Stock
checkbox.

It should only show stock with quantity of 0, but it is also picking up quantity of 30. I think this is becasue it is matching against string values.

I assume issue is with:

ng-true-value='0'


What is best way to fix this? Please can you provide code example?

Answer

Make strict value dynamic:

<div ng-repeat="item in inventory | filter: searchInventory:!!searchInventory.qty | orderBy:sortOrder">

Note: this might get messy if you have multiple similar criterias

http://jsfiddle.net/wYfs4/648/