Created
May 12, 2016 07:55
-
-
Save jhades/25483b615ec7c18cab06bc53f37d7102 to your computer and use it in GitHub Desktop.
Core Directives NgIf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app', | |
template: ` | |
<div class="toggle-panel" *ngIf="show" | |
[hidden]="hidden" [style.visibility]="visibility">Toggle Me</div> | |
<button (click)="toggleShow()">Show</button> | |
<button (click)="toggleHidden()">Hidden</button> | |
<button (click)="toggleVisible()">Visible</button> | |
` | |
}) | |
export class App { | |
show = true; | |
hidden = false; | |
visibility = 'visible'; | |
toggleShow() { | |
this.show = !this.show; | |
} | |
toggleHidden() { | |
this.hidden = !this.hidden; | |
} | |
toggleVisible() { | |
this.visibility = this.visibility == 'visible' ? 'hidden' : 'visible'; | |
} | |
} | |
bootstrap(App); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment