Angular mat-select 下拉 returns 一个未定义的值
Angular mat-select drop down returns an undefined value
HTML:
<mat-form-field>
<mat-select placeholder="Section Types"(selectionChange)="selectSectionType($event)" disableRipple>
<mat-option *ngFor="let type of sectionTypes" [value]="type.value">
{{type.viewValue}}
</mat-option>
</mat-select>
</mat-form-field>
TS:
sectionTypes: DropDown[] = [
{value: '0', viewValue: 'Horizontal'},
{value: '1', viewValue: 'Vertical'}
];
selectSectionType(event: any){
console.log("section type: " + event.target.value);
}
当我 select 来自 mat-select 下拉列表的值时,方法 selectSectionType 被输入但 event.target.value returns 未定义。我想知道为什么。
感谢您的帮助
所选值:
selectSectionType(event: any){
console.log("section type: " + event.value);
}
或
event.source.value
您有一个对象 MatSelect
event.source.MatSelect
HTML:
<mat-form-field>
<mat-select placeholder="Section Types"(selectionChange)="selectSectionType($event)" disableRipple>
<mat-option *ngFor="let type of sectionTypes" [value]="type.value">
{{type.viewValue}}
</mat-option>
</mat-select>
</mat-form-field>
TS:
sectionTypes: DropDown[] = [
{value: '0', viewValue: 'Horizontal'},
{value: '1', viewValue: 'Vertical'}
];
selectSectionType(event: any){
console.log("section type: " + event.target.value);
}
当我 select 来自 mat-select 下拉列表的值时,方法 selectSectionType 被输入但 event.target.value returns 未定义。我想知道为什么。
感谢您的帮助
所选值:
selectSectionType(event: any){
console.log("section type: " + event.value);
}
或
event.source.value
您有一个对象 MatSelect
event.source.MatSelect