import { Component , EventEmitter , OnDestroy , OnInit , Output } from '@angular/core' ; import { Subject } from 'rxjs' ; import { takeUntil } from 'rxjs/operators' ; import { NotaddConfigService } from '@notadd/services/config.service' ; @ Component ( { selector : 'notadd-search-bar' , templateUrl : './search-bar.component.html' , styleUrls : [ './search-bar.component.scss' ] } ) export class NotaddSearchBarComponent implements OnInit , OnDestroy { collapsed : boolean ; notaddConfig : any ; @ Output ( ) input : EventEmitter < any > ; private ngUnsubscribe : Subject < any > ; constructor ( private configService ) { this . input = new EventEmitter ( ) ; this . collapsed = true ; this . ngUnsubscribe = new Subject ( ) ; } ngOnInit ( ) { this . configService . config . pipe ( takeUntil ( this . ngUnsubscribe ) ) . subscribe ( ( config ) => { this . notaddConfig = config ; } ) ; } ngOnDestroy ( ) { this . ngUnsubscribe . next ( ) ; this . ngUnsubscribe . complete ( ) ; } /**
     * 折叠
     */ collapse ( ) { this . collapsed = true ; } /**
     * 展开
     */ expand ( ) { this . collapsed = false ; } param event search ( event ) { this . input . emit ( event . target . value ) ; } }