繁体   English   中英

更新时未选择Angular 8材料特定的垫选项

[英]Angular 8 Material specific mat-option not selected on update

在角度8垫选项未选择特定选项。 我已经把静态选项然后工作正常。 但是,它没有开发动态mat-option。

<mat-label>Item Category  {{item.category_id}}</mat-label>
<mat-select name="category_id" [(ngModel)]="item.category_id" #category_id="ngModel" required>
<mat-option *ngFor="let cat of categoriesData" [value]="cat.id" >
    {{cat.category_title}}
</mat-option>
</mat-select>

我必须解决这个问题。 这是一个惊人的问题。

我的选项值变量是Int(Like:1),发现ngmodel值是来自服务器api的字符串(如:“1”)

<mat-label>Item Category  {{item.category_id}}</mat-label>
<mat-select name="category_id" [(ngModel)]="item.category_id" #category_id="ngModel" required> // found ngmodel variable value is string from server api (like "1")
<mat-option *ngFor="let cat of categoriesData" [value]="cat.id" > // cat.id variable is int (like: 1)
    {{cat.category_title}}
</mat-option>
</mat-select>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM