import { Component, EventEmitter, Output, OnInit } from '@angular/core'; import { FormControl } from '@angular/forms'; @Component({ selector: 'mw-search-bar', templateUrl: './search-bar.component.html', styleUrls: ['./search-bar.component.scss'], }) export class MwSearchBarComponent implements OnInit { searchControl = new FormControl(''); @Output() search = new EventEmitter(); ngOnInit(): void { this.searchControl.valueChanges.subscribe((t) => { this.search.emit(t); }); } onClear(): void { this.searchControl.setValue(''); } }