将值传递给mat-select以选择该选项Angular

问题描述 投票:0回答:1
<mat-form-field>
    <mat-label>Tipo documento</mat-label>
    <mat-select   id="select2" (selectionChange)="loadPath($event.value)" [(ngModel)]="this.valueTipDoc">
      <mat-option *ngFor="let opt of optPath" [value]="opt.id">
        {{opt.name}}
      </mat-option>
    </mat-select>
  </mat-form-field>

我已经使用了ngModel,但是它没有选择任何东西,会有办法吗?

  this.valueTipDoc=this.data1.idPath[0].doctype.toString();
jquery angular material
1个回答
0
投票

您需要ngModel和mat中的名称-使用相同的变量进行选择。例如:

© www.soinside.com 2019 - 2024. All rights reserved.