【问题标题】:How do i add name attribute in mat-option material angular?如何在 mat-option 材料角度中添加名称属性?
【发布时间】:2019-08-26 09:51:22
【问题描述】:

如何在 mat-option 中添加 name 属性?

<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 中添加 name 属性,mat-option 是否有任何替代的 know 属性? 我在 mat-option 标签中使用了 [id]="optionBindingValue"

<mat-option [id]="optionBindingValue">{{optionBindingValue}}</mat-option>

但是这个“ID”属性在检查元素中显示了 2 次。 this [id]="optionBindingValue" 被替换为动态ID属性值。

是否有机会删除一个 ID ?或添加名称属性?或任何替代解决方案?

【问题讨论】:

  • 我可能会先问你想用这个实现什么?

标签: javascript angular angular-material material-design angular-material2


【解决方案1】:

创建一个扩展 mat-select 类的新组件,然后向其中添加所需的字段。检查以下内容:

export class CustomMatSelectComponent extends MatSelect{ public name:string; }

希望有帮助。

【讨论】:

    猜你喜欢
    • 2019-07-16
    • 2019-08-04
    • 1970-01-01
    • 2018-10-11
    • 2020-12-19
    • 1970-01-01
    • 2017-12-08
    • 2018-11-21
    • 1970-01-01
    相关资源
    最近更新 更多