我有这个组件作为父组件(facility.component),我在这个父组件中嵌入了一个子/内部组件(editableTable.component),就像这样
设施组件
<editable-table
[dataList]="nursingUnitList"
(dataListUpdater)="updateNursingUnitList($event)">
<editable-table>
facility.ts(调用服务并从 NursingUnit 表中获取所有数据)
updateNursingUnitList(getUpdate: boolean) {
if (getUpdate == true) {
this.nursingUnitService.getAllUnits().subscribe(
(data: nursingUnit[]) => {
this.nursingUnitList = data;
}
)
在智利/内部组件中,我有这个,
editableTable.ts(通过单击刷新按钮,从 NursingUnit 表中获取最新/刷新的项目列表)
export class EditableTableComponent implements OnInit {
@Input() dataList: any[];
@Output() dataListUpdater = new EventEmitter<boolean>();
refresh() {
this.dataListUpdater.emit(true);
if (this.dataList.length != 0) {
// After getting updated/refreshed list do something here
// but I just got the dataList is null as the compiler not wait for emitter to get the updated/refreshed list from the parent component
}
}
我的问题是如何在发出点等待以获取更新的列表,例如 angular 中的订阅服务或 C# 中的异步等待。
感谢您提供的任何帮助!