Created
May 4, 2017 10:45
-
-
Save bflannery/9494208e1e0707cf94b8314536856a6b to your computer and use it in GitHub Desktop.
This file contains 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: 'friend-tour', | |
template: ` | |
<input #newFriend | |
(keyup.enter)="addFriend(newFriend.value)" | |
(blur)="addFriend(newFriend.value); newFriend.value='' "> | |
<button (click)="addFriend(newFriend.value)">Add</button> | |
<ul><li *ngFor="let friend of friends">{{friends}}</li></ul> | |
` | |
}) | |
export class FriendTourComponent { | |
friends = ['Sophie', 'Tim', 'Jake', 'Steve']; | |
addFriend(newFriend: string) { | |
if (newFriend) { | |
this.friends.push(newFriend); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment