Search code examples
angularjsexpressionparseint

How to parseInt in angularjs expression


I have such type of condition:

<td ng-repeat="sal in name.salaries" 
    ng-if="name.avalue>sal.annual_value">
       Value must be less than or equal to Balance Amount
</td>

Whats happening in real scenario is

For Eg. name.value=1200 sal.annual_value=42 as its not parseInt thats why its considering 42 > 1200.

How can I parseInt() in AngularJS expression?


Solution

  • I would use a scope function to make that verification:

    {...}
    scope.checkSalaries = function(avalue, annual_value) {
       return avalue > annual_value;
    }
    {...}
    

    and in html:

    <td ng-repeat="sal in name.salaries"
        ng-if="checkSalaries(name.avalue,sal.annual_value)">
           Value must be less than or equal to Balance Amount
    </td>