我需要更新 FormArray 中的 'lat' 和 'lon' 值:
initRows() {
return this._fb.group({
address: "",
lat: 0,
lon: 0,
});
}
initForm() {
this.searchForm = this._fb.group({
addresses: this._fb.array([this.initRows()]),
});
我需要在回调后更新它们:
this.someService.getData().subscribe(
(response) => {this.data = response.json()
this.lon = this.data.x;
this.lat = this.data.y;
// UPDATE MY 'lat' and 'lon'
},
(error) => console.log('ERROR: ' + error)
);
form.value 对象:
{
"addresses": [
{
"address": {
"text": "Weberweg, 58566, Kierspe, Nordrhein-Westfalen, DEU"
},
"lat": 0,
"lon": 0
},
{
"address": {
"text": "Weberweg, 58566, Kierspe, Nordrhein-Westfalen, DEU"
},
"lat": 0,
"lon": 0
}
]
}
PS 'lat' 和 'lon' 不是输入,只是数据