Angular material Angular 7无法读取属性';地图';未定义的

Angular material Angular 7无法读取属性';地图';未定义的,angular-material,angular7,Angular Material,Angular7,我在使用mat autocomplete async时遇到了这个问题,我主要在这里尝试了几种解决方案,但即使在那时我也没有成功。遵循我的代码。。。谢谢 组件技术 filteredEmpresas: Observable<IEmpresaResponse>; empresasForm: FormGroup; this.empresasForm = this.fb.group({ empresaInput: null }) this.filte

我在使用mat autocomplete async时遇到了这个问题,我主要在这里尝试了几种解决方案,但即使在那时我也没有成功。遵循我的代码。。。谢谢

组件技术

    filteredEmpresas: Observable<IEmpresaResponse>;
  empresasForm: FormGroup;

this.empresasForm = this.fb.group({
      empresaInput: null
    })

    this.filteredEmpresas = this.empresasForm.get('empresaInput').valueChanges
      .pipe(
        debounceTime(300),
        switchMap(value => this.appService.search({text: value}, 1))
      );

在服务中,如果将其更改为.pipe(点击(res=>console.log(res)),点击((等等…console.log显示了什么?我猜您的响应没有返回一个带有.results字段的对象。您是否检查了浏览器的网络调试控制台?HTTP请求是否实际返回了一个与您期望的结构相同的值?顺便提一下,您不需要在点击中调用构造函数。如果您键入get请求使用IEmpresaResponse,数组结果将已经是Empresa类型,因为预期的json已经被键入。多亏了大家,我决定在服务的“tap((response:any)”中插入any,如果您将其更改为.pipe(tap(res=>console.log(res)),则点击((等等…console.log显示了什么?我猜您的响应没有返回一个带有.results字段的对象。您是否检查了浏览器的网络调试控制台?HTTP请求是否实际返回了一个与您期望的结构相同的值?顺便提一下,您不需要在点击中调用构造函数。如果您键入get请求使用IEmpresaResponse,数组结果将已经是Empresa类型,因为预期的json已经被键入。非常感谢大家,我决定在“tap((response:any)”中插入any
    search(filter: {text: string} = {text: ''}, page = 1): 
  Observable<IEmpresaResponse> {

    return this.http.get<IEmpresaResponse>(this.apiURL + '/busca/'+filter.text)
    .pipe(
      tap((response: IEmpresaResponse) => {
        response.results = response.results
          .map(empresa => new Empresa(empresa.idEmpresa, empresa.nomeEmpresa, empresa.ativo));
        return response;
      })
      );
  }
    export class Empresa {
    constructor(public idEmpresa: number, public nomeEmpresa: string, public ativo: Boolean) {}
  }

  export interface IEmpresaResponse {
    total: number;
    results: Empresa[];
  }