问题描述
实际上这里有两个问题
-
如果输入字符串lenth大于三个字符,我正在尝试获取数据,这是按预期发生的。但 输入第四个字母后,结果数组应自动显示过滤器选项,但单击鼠标会显示列表。
-
IAM在这里使用两个输入自动完成功能,在两种情况下,当用户选择选项时,IAM都会传递两个值($ event,'string')。 在两种情况下,其发送事件值正确无误,但对于其他字符,它总是将第二个输入值作为第二个参数发送。 请帮我解决这个问题。谢谢。
<input type="text" id="src" [formControl]="myControl" placeholder="Pick one" (input)="initService($event)" aria-label="Number" matInput formControlName="source" [matAutocomplete]="auto"> <mat-autocomplete #auto="matAutocomplete" (optionSelected)="stopselect($event,'s');"> <mat-option *ngFor="let option of predictionsNew" [value]="option"> {{option}} </mat-option> </mat-autocomplete> <input type="text" id="dest" placeholder="Pick one" (input)="initService($event)" (input)="initService($event)" aria-label="Number" matInput formControlName="destination" [matAutocomplete]="auto"> <mat-autocomplete #auto="matAutocomplete" (optionSelected)="stopselect($event,'d');"> <mat-option *ngFor="let option of predictionsNew" [value]="option"> {{option}} </mat-option> </mat-autocomplete> initService(event) { this.predictionsNew = []; if (event.target.value.length > 3) { const displaySuggestions = function ( predictions: google.maps.places.QueryAutocompletePrediction[],status: google.maps.places.PlacesServiceStatus,) { if (status != google.maps.places.PlacesServiceStatus.OK) { alert(status); return; } this.predictionsNew = []; for (let i = 0; i < predictions.length; i++) { this.predictionsNew.push(predictions[i].description); } return this.predictionsNew; }; const service = new google.maps.places.AutocompleteService(); service.getQueryPredictions({ input: event.target.value },displaySuggestions.bind(this)); } }
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)