ngIf property
Whether the content of the directive should be visible.
Implementation
@Input()
set ngIf(bool newCondition) {
// Legacy support for cases where `null` is still passed to NgIf.
newCondition = newCondition == true;
if (!checkBinding(_prevCondition, newCondition)) {
return;
}
if (newCondition) {
final viewContainer = _viewContainer;
final templateRef = _templateRef;
if (viewContainer != null && templateRef != null) {
viewContainer.createEmbeddedView(templateRef);
}
} else {
_viewContainer?.clear();
}
_prevCondition = newCondition;
}