Skip to content

Instantly share code, notes, and snippets.

@LayZeeDK
Last active October 19, 2018 22:00
Show Gist options
  • Save LayZeeDK/5b253d24984649aae947fedd1d23dd37 to your computer and use it in GitHub Desktop.
Save LayZeeDK/5b253d24984649aae947fedd1d23dd37 to your computer and use it in GitHub Desktop.
Search component with search BLoC
<div cdkTrapFocus [cdkTrapFocusAutoCapture]="false">
<mat-form-field appearance="outline" style="width: 80%;">
<input
matInput
placeholder="Search for..."
ngModel (ngModelChange)="bloc.query.next($event)">
</mat-form-field>
</div>
<span> {{ bloc.preamble$ | async }} </span>
<ul>
<li *ngFor="let result of bloc.results$ | async">
{{ result }}
</li>
</ul>
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 {
constructor(public readonly bloc: SearchBloc) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment