能否等到安吉特米特林匹兹,如同有可能等待亚克斯呼吁(Angular 5 synchronous HTTP打)一样?
What I want to do is:
A. 儿童部分
@Component({
template: <button (click)="emit1()">emit</button>
})
export class ChildComponent {
@Output() dataChanged: EventEmitter<number> = new EventEmitter<number>(true); // synchronous
emit1(){
this.dataChanged.emit(1)
}
}
父母一方积极创建儿童部分
@Component()
export class ParentComponent {
childComponentRef: ComponentRef<ChildComponent>
constructor(private resolver: ComponentFactoryResolver, private vcRef: ViewContainerRef) {}
openChild() {
const factory = this.resolver.resolveComponentFactory(ChildComponent);
this.childComponentRef = this.vcRef.createComponent(factory);
await this.childComponentRef.instance.dataChanged.toPromise()
alert( emited! )
}
}
我想(a) 放弃,直到从儿童部分获得价值为止。