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
The greater than operator (>) returns TRUE if the first value is greater than the second value. The less than operator (<) returns TRUE if the first value is less than the second value.
Greater than and Less than in Excel to Compare Cell Values We can use the greater than and less than conditional operators between two cell values to compare them. Most of the time, conditional operators are used to compare numbers. The greater than operator (>) returns TRUE if the first value is greater than the second value.
Is it possible to use the 'greater than' comparator in an ng-if in HTML? The problem is that the ">" symbol prematurely closes the HTML tag. is read as: <div ng-if="foo"> (0 class="bar"> HTML STUFF) </div>
Comparing data of different types may give unexpected results. When comparing a string with a number, JavaScript will convert the string to a number when doing the comparison. An empty string converts to 0.
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>
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<20 : {{10<20}}
</div>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With