Angular ng-if = "" with multiple arguments

I am trying to start developing angular. And after reviewing the documentation, some issues remain. What is the best way to write ng-if with a few arguments matching

if( a && b) or if( a || b )

+79
javascript angularjs angular-ng-if
Sep 24 '13 at 17:27
source share
4 answers

It is possible.

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

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

+143
Sep 24 '13 at 17:37
source share
โ€” -

For people who want to do if instructions with multiple meanings or.

 <div ng-if="::(a || b || c || d || e || f)"><div> 
+8
Aug 09 '17 at 15:40
source share

Yes it is possible. e.g. checkout:

 <div class="singleMatch" ng-if="match.date | date:'ddMMyyyy' === main.date && match.team1.code === main.team1code && match.team2.code === main.team2code"> //Do something here </div> 
+2
Apr 17 '17 at 8:31 on
source share

Just to clarify, keep in mind that the location of the brackets is important!

They 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 is recommended that you do not perform the calculations directly in ngIfs, so assign the variables inside your component and execute any logic there.

 boolean check1 = Your conditional check here... ... 
+1
May 31 '19 at 11:49
source share



All Articles