首页 > 解决方案 > 如何在每次更改时获取 Angular 选择的值?

问题描述

我的 html 中有这段代码

        <mat-form-field>
          <mat-label>Country</mat-label>
          <mat-select (change)="selectOpt($event)" required formControlName="country">
            <mat-option *ngFor="let country of countries" [value]="country.name" >
              {{country.name}}
            </mat-option>
          </mat-select>
        </mat-form-field>

每次选择不同的东西时,如何获取 select 的值?我的 mat-select 中有(更改)事件,但它没有捕捉到该事件

标签: angularhtml-selectonchange

解决方案


改变(selectionChange)="selectOpt($event)"它,它会工作


推荐阅读