Skip to content

Instantly share code, notes, and snippets.

@LayZeeDK
Last active July 15, 2018 21:41
Show Gist options
  • Save LayZeeDK/5134283d80d8f548c0c9da22d6b4eaa5 to your computer and use it in GitHub Desktop.
Save LayZeeDK/5134283d80d8f548c0c9da22d6b4eaa5 to your computer and use it in GitHub Desktop.
Heroes: Mixed component template
<h2>My Heroes</h2>
<div>
<label>Hero name:
<input #heroName />
</label>
<!-- (click) passes input value to add() and then clears the input -->
<button (click)="add(heroName.value); heroName.value=''">
add
</button>
</div>
<ul class="heroes">
<li *ngFor="let hero of heroes">
<a routerLink="/detail/{{hero.id}}">
<span class="badge">{{hero.id}}</span> {{hero.name}}
</a>
<button class="delete" title="delete hero"
(click)="delete(hero)">x</button>
</li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment