【问题标题】:md-select and required doesn't detect empty value [duplicate]md-select 和 required 未检测到空值 [重复]
【发布时间】:2026-01-29 19:05:02
【问题描述】:

我正在尝试使用 angularjs 和 md-select 进行选择选项。 问题是,<md-option ng-value=""></md-option> 什么也没做。

我在 github 上看到了多个问题,但没有有效的修复。

<md-input-container>
    <md-select  ng-change="$ctrl.onFieldChanged(field)"
                ng-required="true">
        <md-option ng-value=""></md-option>
        <md-option ng-repeat="option in field['options'] | orderBy: 'sort_id' | filter : {enabled: true}"
                ng-value="option.o_id">
            {{ option.value }}
        </md-option>
    </md-select>
    <div ng-messages="itemDetailsForm[field.title].$error">
        <div ng-message="required">{{ 'INPUT_ERR.REQUIRED' | translate }}</div>
    </div>
</md-input-container>

【问题讨论】:

  • 不知道为什么发了两次

标签: angularjs md-select ng-required


【解决方案1】:

这是材料设计长期存在的问题

你可以试试&lt;md-option ng-value="''"&gt;

【讨论】: