我正在尝试使用angularjs和md-select使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>
答案 0 :(得分:1)
这是材料设计中长期存在的问题
您可以尝试<md-option ng-value="''">