Angular Material: mat-select not selecting default

后端 未结 17 1385
不思量自难忘°
不思量自难忘° 2020-11-28 23:18

I have a mat-select where the options are all objects defined in an array. I am trying to set the value to default to one of the options, however it is being left selected

17条回答
  •  一向
    一向 (楼主)
    2020-11-29 00:13

    The solution for me was:

    
      
      {{moneda.detalle}}
    
    

    TS:

    @ViewChild('monedaSelect') public monedaSelect: MatSelect;
    this.genericService.getOpciones().subscribe(res => {
    
      this.monedasList = res;
      this.monedaSelect._onChange(res[0].id);
    
    
    });
    

    Using object: {id: number, detalle: string}

提交回复
热议问题