Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular ng-if not true

Why doesn't this work.

<li ng-if="!area"></li>

Feels a bit illogical since

<li ng-if="area"></li>

works just fine.

'area' is defined in scope as true/false Any workarounds for this? I would prefer not to use ng-show/ng-hide since both of them renders items in DOM.

like image 587
user3289197 Avatar asked Oct 08 '14 20:10

user3289197


People also ask

What is * ngIf?

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.

Can we use ngIf in P tag?

NgIf is a directive That means, that it can be added to any tag in your template. This includes regular HTML-tags like the "p"-tag shown above and even angular component selectors.


1 Answers

use this

ng-if="area == false"

OR

ng-if="area == true"

this may help someone

like image 170
Sachin Sudhakar Sonawane Avatar answered Oct 09 '22 02:10

Sachin Sudhakar Sonawane