Javascript google places api不适用于使用ionic 4生成的文本字段
下面的代码用于添加文本字段dynamicali,这个文本字段是一个goole places自动完成列表,我的问题是goole places api只对第一个字段起作用,不起作用。对于生成的字段 .html [![在此处输入图像描述][1][1] [![在此处输入图像描述][2][2]Javascript google places api不适用于使用ionic 4生成的文本字段,javascript,angular,google-maps,ionic4,Javascript,Angular,Google Maps,Ionic4,下面的代码用于添加文本字段dynamicali,这个文本字段是一个goole places自动完成列表,我的问题是goole places api只对第一个字段起作用,不起作用。对于生成的字段 .html [![在此处输入图像描述][1][1] [![在此处输入图像描述][2][2] 我添加了一些图片来大致了解这个问题,第一张图片你看到的是我制作的UI,第二张是当我尝试键入一个城市时google places api正在工作,但当我单击按钮添加新城市时,文本字段生成了,但google place
我添加了一些图片来大致了解这个问题,第一张图片你看到的是我制作的UI,第二张是当我尝试键入一个城市时google places api正在工作,但当我单击按钮添加新城市时,文本字段生成了,但google places api不工作,这就是问题所在。以下是我认为在您的代码中发生的情况:
@ViewChildren('autoStation') autoStationList:QueryList<any>;
这就是我在wok所说的完美,非常感谢,事实上,这是一个混乱的代码,我必须处理,谢谢你的帮助,thaks
@ViewChild('autoStation', {static: true}) autoStation: any;
ngAfterViewInit(): void {
this.autoCompleteStation.forEach( autoStation => {
autoStation.getInputElement().then(( input: HTMLInputElement) => {
var autocompl = new google.maps.places.Autocomplete(input, {
//somee code
});
}
});
addNewInputField() : void {
const control = this.form.controls.technologies as FormArray;
control.push(this.initTechnologyFields());
}
removeInputField(i : number) : void {
const control = this.form.controls.technologies as FormArray;
control.removeAt(i);
}
@ViewChildren('autoStation') autoStationList:QueryList<any>;
ngAfterViewInit(): void {
// here you initialize all ion-input's native inputs that exist in DOM at component view initialization stage:
this.autoCompleteStation.forEach( autoStation => {
autoStation.getInputElement().then(( input: HTMLInputElement) => {
let autocompl = new google.maps.places.Autocomplete(input, {
//some code
})
});
// here you subscribe to changes for the list:
this.autoStationList.changes.subscribe(list => {
// here we need to use "last" property of the list:
list.last.getInputElement().then(( input: HTMLInputElement) => {
var autocompl = new google.maps.places.Autocomplete(input, {
//somee code
})
})
});
}