Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 谷歌自动完成的建议不合适的角度_Angular_Google Maps_Dialog - Fatal编程技术网

Angular 谷歌自动完成的建议不合适的角度

Angular 谷歌自动完成的建议不合适的角度,angular,google-maps,dialog,Angular,Google Maps,Dialog,我使用谷歌自动完成在角垫对话框 我在mat对话框中添加了搜索字段 当我搜索某物时,建议会自动出现在搜索栏的顶部或上方 你知道我该如何解决或指导我吗。?请注意,这是一个mat对话框。 我哪里做错了。 下面是我的代码 app.html <div *ngIf="!passAddressCheck"> <p class="montserratSemiBold fontSize22px">Seach of an address</p> <div

我使用谷歌自动完成在角垫对话框

我在mat对话框中添加了搜索字段

当我搜索某物时,建议会自动出现在搜索栏的顶部或上方

你知道我该如何解决或指导我吗。?请注意,这是一个mat对话框。 我哪里做错了。 下面是我的代码

app.html

<div *ngIf="!passAddressCheck">
    <p class="montserratSemiBold fontSize22px">Seach of an address</p>
    <div class="marginBottom30px marginTop30px">
      <div class="container">
        <div class="form-group">
          <input autocorrect="off" autocapitalize="off" spellcheck="off" type="text" class="form-control" #search [formControl]="searchControl">
        </div>
      </div>
    </div>
    <p *ngIf="showErrorAddress" class="errorColor fontSize14px montserratRegular marginBottom30px">Sorry we do not deliver to you address at this moment</p>
  </div>

您必须在对话框HTML中使用指令mat对话框标题、mat对话框内容,以便正确使用每个元素,您的问题似乎与CSS有关。试着在stackblitz上复制它来帮助你。这似乎不是问题。我刚试过。但我确实发现了一点,那就是建议框在对话框后面的滚动页面后面。因此,当我向上滚动并按下对话框按钮时,建议将显示在输入的正下方。但当我向下滚动时,建议会出现在屏幕顶部。有同样的问题。。。找到解决方案了吗?我的解决方案是使用启动对话框
searchControl: FormControl;

this.searchControl = new FormControl();


@ViewChild('search', {static: false})
public searchElementRef: ElementRef;
this.mapsAPILoader.load().then(() => {
      const autocomplete = new google.maps.places.Autocomplete(this.searchElementRef.nativeElement, {
        componentRestrictions: {country: 'my'}
      });

      autocomplete.addListener('place_changed', () => {
        this.ngZone.run(() => {

          const place: google.maps.places.PlaceResult = autocomplete.getPlace();

          if (place.geometry === undefined || place.geometry === null) {
            return;
          }

          this.latitude = place.geometry.location.lat();
          this.longitude = place.geometry.location.lng();
          this.zoom = 12;

        });
      });
    });
  }