【发布时间】:2019-09-19 15:39:11
【问题描述】:
我正在尝试将选定的值从 HTML 获取到 ts 文件中。下面是使用 Angular 材质标签的 HTML 代码
<mat-form-field [style.visibility]="visibility" >
<mat-label>Apps</mat-label>
<mat-select #selectedApp (change)='fetchTableData($event)'>
<mat-option *ngFor="let apps of appsList$" [value]="apps.appName">{{apps.appName}}</mat-option>
<mat-option [value]="all">All</mat-option>
</mat-select>
</mat-form-field>
.ts 代码
@ViewChild('selectedApp') selectedApp;
ngOnInit() {
return this.testcaseService.getAll()
.subscribe(apps => this.appsList$ = apps);
}
fetchTableData(event: any){
console.log("Selected App: "+this.selectedApp.Selected);
}
我不确定我在这里做错了什么。谁能帮帮我
【问题讨论】:
标签: angular