NgIf
Last updated
Was this helpful?
Last updated
Was this helpful?
The asterisk *
is "syntactic sugar" for something a bit more complicated. Internally, Angular translates the *ngIf
attribute into a <ng-template>
element, wrapped around the host element.
Render result :
Angular consumed the <ng-template>
content during its actual rendering and replaced the <ng-template>
with a diagnostic comment.
The component and DOM nodes can be garbage-collected and free up memory.
When the condition is false,removes its host element from the DOM, detaches it from DOM events (the attachments that it made), detaches the component from Angular change detection, and destroys it.