【问题标题】:How to take the value of an Angular select each time it changes?如何在每次更改时获取 Angular 选择的值?
【发布时间】:2020-04-29 03:45:24
【问题描述】:

我的 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 中有(更改)事件,但它没有捕捉到该事件

【问题讨论】:

    标签: angular html-select onchange


    【解决方案1】:

    更改(selectionChange)="selectOpt($event)" 即可使用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-02
      • 1970-01-01
      • 1970-01-01
      • 2010-09-20
      相关资源
      最近更新 更多