How to express a condition in ng-if directive ?
Right now I tried this
<div ng-if="{ selectedTab == 'decoupage'}"> ... Syntax Error: Token '==' is unexpected, expecting [:] at column 15 of the expression [{ selectedTab == 'decoupage'}] starting at [== 'decoupage'}].
I'm using Angular 1.2.0.
We can use multiple conditions in *ngIf with logical operator AND (&&) to decide the trustworthy of *ngIf expression. If all conditions are true, then element will be added to the DOM.
A shorthand form of the directive, *ngIf="condition" , is generally used, provided as an attribute of the anchor element for the inserted template. Angular expands this into a more explicit version, in which the anchor element is contained in an <ng-template> element.
Definition and Usage The ng-if directive removes the HTML element if the expression evaluates to false. If the if statement evaluates to true, a copy of the Element is added in the DOM.
ng-if
is already in an angular context so you can just do this:
ng-if="selectedTab == 'decoupage'"
For future reference:
{{ }}
-> are for interpolation{ }
I've only seen in ng-class
for boolean expression resolution.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