Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 询问childcomponent并等待结果_Angular - Fatal编程技术网

Angular 询问childcomponent并等待结果

Angular 询问childcomponent并等待结果,angular,Angular,我有一个父组件,它是一个列表,一个子组件显示详细信息,它允许用户编辑这些详细信息。我正在寻找一种方法,在允许用户更改选择之前,询问我的子组件是否还有任何未保存的更改 当前设置: 家长(简化): dx树列表(onRowClick)=“编辑状态($event)” 这些更改是在副本上进行的,因此列表不会同时更新 所以我需要一种方法来检查childcomponent上的更改(它有一个函数hasChanges,但与selectedStatus比较),所以在检查之前可能不会更改,这意味着需要在“getEdi

我有一个父组件,它是一个列表,一个子组件显示详细信息,它允许用户编辑这些详细信息。我正在寻找一种方法,在允许用户更改选择之前,询问我的子组件是否还有任何未保存的更改

当前设置: 家长(简化): dx树列表(onRowClick)=“编辑状态($event)”

这些更改是在副本上进行的,因此列表不会同时更新


所以我需要一种方法来检查childcomponent上的更改(它有一个函数hasChanges,但与selectedStatus比较),所以在检查之前可能不会更改,这意味着需要在“getEditableStatus”之前检查它。是否有其他方法将布尔值传递给子对象,然后该子对象依次发出另一个值?

我找到了它,我的原始想法是不可能的。。。这是:

@ViewChild(ProjectStatusDetailComponent, { static: false }) childComponent: ProjectStatusDetailComponent;

if (!!this.childComponent) {
   console.log(this.childComponent.hasChanges());
}
    ngOnChanges(): void {
        if (!!this.selectedStatus) {
            this.selectedStatusCopy = _.cloneDeep(this.selectedStatus);
        }
    }
@ViewChild(ProjectStatusDetailComponent, { static: false }) childComponent: ProjectStatusDetailComponent;

if (!!this.childComponent) {
   console.log(this.childComponent.hasChanges());
}