angular-material - mat-select 在 SelectionChange() 上返回 undefined
问题描述
我有 mat-select on (selectionChange) 事件,我收到 undefined 作为$event.value
. 它为第一个 mat-option.mat-option 返回正确的值,其值为 'All' 它给出 undefined
<mat-form-field>
<mat-select [(value)]="regionOption" (selectionChange)="regionSelectionChange($event)"
placeholder="Region">
<mat-option *ngFor="let region of regions" [value]="region.location_name">{{region.location_name}}</mat-option>
<mat-option [value]="All" >All</mat-option>
</mat-select>
</mat-form-field>
//ts
regionSelectionChange(regionName)
{
console.log(regionName);
}
解决方案
将值绑定从 [value] 更改为 value
<mat-option value="All">All</mat-option>
推荐阅读
- ios - Flutter fastlane ios如何通过--dart-define
- graphql - 有没有办法避免在 Apollo GraphQL 中返回具有空值的键?
- java - 如何在 JavaFX 中的 tabpane 之间添加拆分?
- django - 加载图像时没有这样的文件或目录
- asp.net-core - 如何从 asp.net core 3.1 项目的已发布文件创建整个解决方案?
- docker - Golang,Docker,外部包,找不到路径
- flutter - 向下滚动 ListviewItmes 时,强制屏幕小部件的顶部继续显示,颤振
- mongodb - 使用它们的 _ids 作为比较来删除文档
- c# - 使用 IdentityServer4 和 DataProtection API 进行令牌签名
- java - 用postgresql中的查询替换java循环