如何在mat-option中添加名称属性?
<mat-option class="mat-option ng-star-inserted" role="option" ng-reflect-value="[object Object]" ng-reflect-id="someoptionValue1" tabindex="0" id="someoptionValue1" id="someoptionValue1" aria-disabled="false">
<span class="mat-option-text"> Ocean-LCL (NVOCC) </span>
<div class="mat-option-ripple mat-ripple" mat-ripple="" ng-reflect-disabled="false" ng-reflect-trigger="[object HTMLElement]">
</div>
</mat-option>
如果无法在 mat-option 中添加名称属性,是否有任何替代已知属性到mat-option? 我在mat-option标签中使用了[id]="optionBindingValue">
<mat-option [id]="optionBindingValue">{{optionBindingValue}}</mat-option>
但是这个"ID"属性在检查元素中显示 2 次。 此 [id]="optionBindingValue" 将替换动态 ID 属性值。
有没有机会删除一个 ID 或添加名称属性? 还是任何替代解决方案?
创建一个扩展 mat-select 类的新组件,然后向其添加所需的字段。 检查以下内容:
export class CustomMatSelectComponent extends MatSelect{
public name:string;
}
希望有帮助。