I have this component as a Parent component (facility.component), and I embedded a child/inner component (editableTable.component) inside this parent component, something like this
facility.component
<editable-table
[dataList]="nursingUnitList"
(dataListUpdater)="updateNursingUnitList($event)">
<editable-table>
facility.ts (call a service and get all data from a NursingUnit table)
updateNursingUnitList(getUpdate: boolean) {
if (getUpdate == true) {
this.nursingUnitService.getAllUnits().subscribe(
(data: nursingUnit[]) => {
this.nursingUnitList = data;
}
)
And in chile/inner component I have this,
editableTable.ts (by click on Refresh button, getting latest/refreshed item list from NursingUnit table)
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
}
}
My question is how can I wait at the emit point to get the updated list, something like subscribe services in angular or async await in C#.
Thank you for anything you can do to help!