Last active
May 19, 2018 18:07
-
-
Save alexzuza/768bbfa3115de3dec8764ba33eb308bd to your computer and use it in GitHub Desktop.
Example ivy
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: 'my-app', | |
template: ` | |
<h2>Parent</h2> | |
<child [prop1]="x"></child> | |
` | |
}) | |
export class AppComponent { | |
x = 1; | |
} | |
@Component({ | |
selector: 'child', | |
template: ` | |
<h2>Child {{ prop1 }}</h2> | |
<sub-child [item]="3"></sub-child> | |
<sub-child *ngFor="let item of items" [item]="item"></sub-child> | |
` | |
}) | |
export class ChildComponent { | |
@Input() prop1: number; | |
items = [1, 2]; | |
} | |
@Component({ | |
selector: 'sub-child', | |
template: ` | |
<h2 (click)="clicked.emit()">Sub-Child {{ item }}</h2> | |
<input (input)="text = $event.target.value"> | |
<p>{{ text }}</p> | |
` | |
}) | |
export class SubChildComponent { | |
@Input() item: number; | |
@Output() clicked = new EventEmitter(); | |
text: string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment