parseFloat not working in angularjs view

angularjs

Solution

Take a look at this fiddle

You can use option 1 (as you have it) but you need to use `class` not `ng-class`

<a class="{{(parseFloat('-0.56%') < 0) ? 'true1' : 'false'}}">Option 1</a>

In order to use `ng-class` use this:

<a ng-class="{'true': (parseFloat('-0.56%') < 0), 'false': (parseFloat('-0.56%') >= 0)}">Option 2a</a>    
<a ng-class="{'true': (parseFloat('0.56%') < 0), 'false': (parseFloat('0.56%') >= 0)}">Option 2b</a>

The difference being is that `ng-class` takes an object where the `key` is the class and the `value` is the boolean evaluation to determine if the class gets added to the element.

Problem

The following conditional return false inside a angular view: ``` <a ng-class="(parseFloat('-0.56%') < 0) ? 'true' : 'false'">...</a> ``` I've already added the parseFloat method in $scope. ``` $scope.parseFloat = parseFloat; ``` Thanks for any help.

Original source