角度谷歌地图的地方自动完成输入不显示在输出上

时间:2018-11-11 20:21:00

标签: angular reactive-programming mean-stack angular-reactive-forms angular-google-maps

我正在Angular 6项目中工作,我的两个地址输入表单正在使用AGM集成places API,并假定为最终用户显示地址建议以简化数据输入。但是,将表单数据提交到数据库后,结果仅显示整个地址的前三个或四个字母,请在下面查看更多信息:

<mat-form-field>
    <input matInput placeholder="pickUp Address" autocorrect="off" autocapitalize="off" spellcheck="off" google-place type="text" formControlName="pickUpAddress">
  <!-- <input matInput type="text" formControlName="pickUpAddress" placeholder="pickUp Address"> -->
  <mat-error *ngIf="form.get('pickUpAddress').invalid">Please enter a Pickup Address.</mat-error>
</mat-form-field>
<mat-form-field>
    <input matInput placeholder="dropoff Address" autocorrect="off" autocapitalize="off" spellcheck="off" google-place type="text"  formControlName="schoolLocation">
  <!-- <input matInput type="text" formControlName="schoolLocation" placeholder="school Name"> -->
  <mat-error *ngIf="form.get('schoolLocation').invalid">Please enter a dropoff address.</mat-error>
</mat-form-field>

在保存/提交时,我使用了component.ts文件下面的脚本来获取输入/表单的值:

onSavePost() {
if (this.form.invalid) {
  return;
}
this.isLoading = true;
if (this.mode === 'create') {
  this.postsService.addPost(
    this.form.value.pickUpAddress,
    this.form.value.schoolLocation
  );
} else {
  this.postsService.updatePost(
    this.postId,
    this.form.value.pickUpAddress,
    this.form.value.schoolLocation
  );

下面的图片显示了我在说什么,用户实际上是在搜索哈尔西大街65号和圣迈克尔学校。

Output of address result

0 个答案:

没有答案