import { Component , ElementRef , ViewChild } from '@angular/core' ; @ Component ( { selector : 'app' , templateUrl : './app.component.html' , styleUrls : [ './app.component.css' ] } ) export class AppComponent { expanded : boolean ; searchText : string ; searchedFor : string = '' ; @ ViewChild ( 'searchFieldRight' ) searchFieldRight : ElementRef ; onSearch ( searchText ) { this . searchedFor = searchText ; this . expanded = false ; } onSearchRight ( searchText ) { this . searchedFor = searchText ; this . searchFieldRight . nativeElement . blur ( ) ; } }