我在仪表板组件中,在仪表板组件中,我有一个模态。在模式中,我将另一个组件称为B-Comp。在B-comp中进行了一些更改之后,我将关闭模式,然后B-comp将关闭,现在它又回到了Dashboard组件中。在仪表板上如何获取B-compo数据更改?
您可以在BComp中使用@Output()
装饰器来传递数据,例如
@Component({
selector: 'b-component'
})
export class BComponent {
@Output()
public close: EventEmitter<any> = new EventEmitter();
public onClose() {
this.close.emit(this.myData)
}
}
在您的仪表板组件中
dashboard.component.html
<b-component (close)="onMyBComponentClose($event)"></b-component>
dashboard.component.ts
...
public onMyBComponentClose(bData) {
console.log(bData)
}
...