如何解决材质自动完成填充的数据未显示在字符输入中,而是在单击鼠标时显示?
实际上这里有两个问题
-
如果输入字符串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 举报,一经查实,本站将立刻删除。