Angular Ng-if="" With Multiple Arguments


Answer :

It is possible.

<span ng-if="checked && checked2">   I'm removed when the checkbox is unchecked. </span> 

http://plnkr.co/edit/UKNoaaJX5KG3J7AswhLV?p=preview


For people looking to do if statements with multiple 'or' values.

<div ng-if="::(a || b || c || d || e || f)"><div> 

Just to clarify, be aware bracket placement is important!

These can be added to any HTML tags... span, div, table, p, tr, td etc.

AngularJS

ng-if="check1 && !check2" -- AND NOT ng-if="check1 || check2" -- OR ng-if="(check1 || check2) && check3" -- AND/OR - Make sure to use brackets 

Angular2+

*ngIf="check1 && !check2" -- AND NOT *ngIf="check1 || check2" -- OR *ngIf="(check1 || check2) && check3" -- AND/OR - Make sure to use brackets 

It's best practice not to do calculations directly within ngIfs, so assign the variables within your component, and do any logic there.

boolean check1 = Your conditional check here... ... 

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable