Skip to content

Instantly share code, notes, and snippets.

@ashish173
Created December 19, 2016 02:09
Show Gist options
  • Save ashish173/f699749c940924c458f433e3dd51eba3 to your computer and use it in GitHub Desktop.
Save ashish173/f699749c940924c458f433e3dd51eba3 to your computer and use it in GitHub Desktop.
Update view for NgIf Else Directive
private _updateView() {
if (this._context.$implicit) {
if (!this._thenViewRef) {
this._viewContainer.clear();
this._elseViewRef = null;
if (this._thenTemplateRef) {
this._thenViewRef =
this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
}
}
} else {
if (!this._elseViewRef) {
this._viewContainer.clear();
this._thenViewRef = null;
if (this._elseTemplateRef) {
this._elseViewRef =
this._viewContainer.createEmbeddedView(this._elseTemplateRef, this._context);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment