Skip to content

Instantly share code, notes, and snippets.

@splincode
Created January 3, 2019 08:55
Show Gist options
  • Save splincode/877b16712d690f3880dffb21616910dd to your computer and use it in GitHub Desktop.
Save splincode/877b16712d690f3880dffb21616910dd to your computer and use it in GitHub Desktop.
@Component({
selector: 'app-animal',
template: `
<ng-container *ngFor="let animals of animals$ | async">
<p>{{ animal }}</p>
</ng-container>
<input #inputAnimal placeholder='Add new animal' />
<button (click)="addAnimal.emit(inputAnimal.value)">
Add animal
</button>
`
})
export class CounterComponent {
@Select(AnimalState)
public animals$: Observable<string[]>;
@Emitter(AnimalState.addAnimal)
public addAnimal: Emittable<string>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment