Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Conditional in HTML does not like less than or greater than symbols

Tags:

angular

Simple question, cannot seem to find an answer... (this will be a quick 'point' for someone)

I'm looking to have a condition in an Angular 5 ngIf be "less than" some variable.

<div class="row" *ngIf="Subject < 4" >
<div class="row" *ngIf="Subject <= 4" >

this syntax bombs because "<" - how can I do this? (without having to write function)?

like image 742
j-p Avatar asked Nov 04 '18 18:11

j-p


People also ask

How do I check if ngIf is less than?

*ngIf doesn't work with '<=' sign. Need to check equal(==), less than(<) and greater than(>) conditions separately with OR operator. Some IDE might show '<' or '>' sign in as syntax error while writing the code, because these are used for HTML tags also. But, it will not throw any compile or run time error.


1 Answers

<div class="row" *ngIf="4 > Subject">
<div class="row" *ngIf="4 >= Subject">

And you're done Works perfect for me

like image 149
Loïc Desjacques Avatar answered Oct 27 '22 03:10

Loïc Desjacques