Yashpal Singla
Yashpal Singla

Reputation: 1994

How to make less than or greater than comparison in angularjs

Please anybody explain how to do below check in angularjs

<div ng-show="{{offset <= 10}}">Show Me</div>

If i run it like this it breaks the html, i think due to "<" than in comparison

Upvotes: 16

Views: 60962

Answers (3)

Sanu Joseph
Sanu Joseph

Reputation: 31

You can also try this, it works!

<!DOCTYPE html>
 <html>
  <script  src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
  </script>
 <body>
  <div  ng-app="">
    10&lt;20 : {{10&lt;20}}
  </div>
 </body>
</html>

Upvotes: 3

Dharmendra Chaudhary
Dharmendra Chaudhary

Reputation: 37

You can use like this.

{{ data[0].Insight_Value_2 <= 15 ?data[0].Insight_Value_2 : data[0].Insight_Value_2/2 }}

It works.

Upvotes: 0

Mark Rajcok
Mark Rajcok

Reputation: 364707

Don't use {{}}s:

<div ng-show="offset <= 10">Show Me</div>

The expression given to ng-show is evaluated against the current scope, so there is no need for interpolation – the {{}}s.

You would need the {{}}s if you wanted to do something like this:

<div>Offset is <= 10: {{offset <= 10}}</div>

Upvotes: 26

Related Questions