md-select and required doesn't detect empty value

391 Views Asked by At

I am trying to make a select option has required using angularjs and md-select. The problem is, <md-option ng-value=""></md-option>is not doing anything.

I've seen multiple issue on github, but no valid fix.

<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>
1

There are 1 best solutions below

0
On

This is long running issue with material design

you can give a try to <md-option ng-value="''">