Angular 如何在角度传感器中将数据从父元件传回子元件

Angular 如何在角度传感器中将数据从父元件传回子元件,angular,typescript,angular10,Angular,Typescript,Angular10,我在我的子组件中使用GooglePlaceAutoComplete,但是当每个输入都充满数据时,父组件没有得到更改,因此我无法将有效数据发布到服务器 我在父组件中调用了一个子组件: 在子组件中,google place input调用handleAddressChange函数: Pontos cím Kereseése handleAddressChange函数正在更改输入的值,但accountData不会更新 handleAddressChange(事件){ 让地址:地址; this.z

我在我的子组件中使用GooglePlaceAutoComplete,但是当每个输入都充满数据时,父组件没有得到更改,因此我无法将有效数据发布到服务器

我在父组件中调用了一个子组件:


在子组件中,google place input调用handleAddressChange函数:

Pontos cím Kereseése
handleAddressChange函数正在更改输入的值,但accountData不会更新

handleAddressChange(事件){
让地址:地址;
this.zipModel='';
this.cityModel='';
this.addressNameModel='';
this.addressTypeModel='';
this.addressNumberModel='';
this.addressFloorDoorModel='';
this.addressCoordsModel={
lat:event.geometry.location.lat(),
lng:event.geometry.location.lng()
};
address=this.regionHelper.setAddressParts(this.clientRegion,event.address\u组件);
this.countryModel=address.country;
this.zipModel=address.zip;
this.cityModel=address.city;
this.addressNameModel=address.addressName;
this.addressTypeModel=address.addressType;
this.addressNumberModel=address.addressNumber;
}

如果我在输入中键入的是正常工作的手动输入。

最好在子组件中有一个输出事件发射器(最好有一个包含所有AccountData的输入),并且父对象需要管理此事件。例如:

家长需要这个

parentDetectChanges(newData: any){
    //put the new values here


}

HTML

<child-component [accountData]="accountDataObject" (changesOnChild)="parentDetectChanges(event)" > </child-component>
儿童

@Input() accountData: AccountData;
@Output() changesOnChild = new EventEmitter<AccountData>();

....
some code
....

handleAddressChange(event) {
    //modify account data object

    ...

    this.changesOnChild.emit(this.accountData)
}


@Input()accountData:accountData;
@Output()changesOnChild=neweventemitter();
....
一些代码
....
handleAddressChange(事件){
//修改帐户数据对象
...
this.changesOnChild.emit(this.accountData)
}

在子组件中最好有一个输出事件发射器(最好有一个包含所有AccountData的输入),并且父对象需要管理此事件。例如:

家长需要这个

parentDetectChanges(newData: any){
    //put the new values here


}

HTML

<child-component [accountData]="accountDataObject" (changesOnChild)="parentDetectChanges(event)" > </child-component>
儿童

@Input() accountData: AccountData;
@Output() changesOnChild = new EventEmitter<AccountData>();

....
some code
....

handleAddressChange(event) {
    //modify account data object

    ...

    this.changesOnChild.emit(this.accountData)
}


@Input()accountData:accountData;
@Output()changesOnChild=neweventemitter();
....
一些代码
....
handleAddressChange(事件){
//修改帐户数据对象
...
this.changesOnChild.emit(this.accountData)
}

家长通过属性将数据传递给孩子,通过事件将数据传递给家长。您使用的是什么
ChangeDetectionStrategy
?我使用的是默认策略。家长通过属性将数据传递给孩子,通过事件将数据传递给家长。您使用的是什么
changedtectionstrategy
?我使用的是默认策略。