[英]selectionChange in mat-select not working Angular 13
我創建了一個帶有 selectionChange 事件的 mat-select,但是當值被更改時,事件沒有被觸發。
html 文件
<mat-select (selectionChange)="changeCategory()">
<mat-option *ngFor="let category of categoryList" [value]="category._id">{{category.name}} </mat-option> </mat-select>
文件
changeCategory(){
console.log('ok')
}
在您的app.module.ts中導入MatSelectModule
我准備了一個工作演示來展示selectionChange
的用法,因此您可以將其與您的案例進行比較,看看缺少什么: 工作演示
每次更改選擇時,模板中的數字都會增加 1,以表明事件已被觸發。 我希望它有所幫助。
<mat-select
(selectionChange)="select($event)"
required
formControlName="adquiriente"
>
你可以這樣試試
select(event) {
console.log(event.value);
// let value = event.
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.