小编Rfo*_*xes的帖子

类型错误:无法读取未定义的属性“自动完成”

错误错误:未捕获(承诺中):类型错误:无法读取未定义的属性“自动完成”类型错误:无法读取未定义的属性“自动完成”

当我运行 Angular 应用程序时,此错误不断弹出。它说我的 search.component.ts 文件第 25 行有问题。这是我的搜索组件

    /// <reference types="@types/googlemaps" />
import { Component, OnInit, ViewChild, ElementRef, NgZone } from '@angular/core';
import { FormControl } from '@angular/forms';
import { MapsAPILoader } from '@agm/core';

@Component({
  selector: 'app-search',
  templateUrl: './search.component.html',
  styleUrls: ['./search.component.scss'],
})
export class SearchComponent implements OnInit {

  autocomplete: any;
  @ViewChild('search')
  public searchElementRef: ElementRef;
  public searchControl: FormControl;

  constructor(private zone: NgZone, 
    private mapsAPILoader: MapsAPILoader) { }

  ngOnInit() {
    this.searchControl = new FormControl();

    this.mapsAPILoader.load().then(() => {
        let autocomplete = new window['google'].maps.places.Autocomplete(this.searchElementRef.nativeElement, { …
Run Code Online (Sandbox Code Playgroud)

typeerror google-places-api angular

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

angular ×1

google-places-api ×1

typeerror ×1