Answers for "wait EventEmitter return"

0

wait EventEmitter return

// FILE : child.component.ts
@Input()
set response (v: any) {
 // Do some logic here
}

@Output() 
callParentFunction = new EventEmitter<any>();

doStuff () {
 this.callParentFunction.emit();
}


// FILE : parent.component.ts
public response$: Observable<IResponse | null> = of(null);

parentFunction(){
    this.response$ = this.http.get(/* ... */)
}


// FILE : parent.component.html
<child-component
  [response]="response$ | async" 
 (callParentFunction)="parentFunction($event)"
></child-component>
Posted by: Guest on February-25-2021

Browse Popular Code Answers by Language