Created
October 19, 2018 21:59
-
-
Save LayZeeDK/496a4251ae326320ad9e3f6886416259 to your computer and use it in GitHub Desktop.
Search component that delegates to search BLoC
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
<div cdkTrapFocus [cdkTrapFocusAutoCapture]="false"> | |
<mat-form-field appearance="outline" style="width: 80%;"> | |
<input | |
matInput | |
placeholder="Search for..." | |
ngModel (ngModelChange)="search($event)"> | |
</mat-form-field> | |
</div> | |
<span> {{ preamble$ | async }} </span> | |
<ul> | |
<li *ngFor="let result of results$ | async"> | |
{{ result }} | |
</li> | |
</ul> |
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
import { Component } from '@angular/core'; | |
import { SearchBloc } from '../../business-logic/search'; | |
@Component({ | |
selector: 'app-search', | |
styleUrls: ['./search.component.css'], | |
templateUrl: './search.component.html', | |
}) | |
export class SearchComponent { | |
readonly preamble$ = this.bloc.preamble$; | |
readonly results$ = this.bloc.results$; | |
constructor(private readonly bloc: SearchBloc) {} | |
search(query: string): void { | |
this.bloc.query.next(query); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment