我在表單上有幾個md-select下拉列表,其中很多都有驗證。驗證正常工作在所有的下拉菜單,除了以下,這並不妨礙形式從提交如果空:角質材料md-select驗證問題
<md-input-container class="form-input-container"
flex="15">
<label>NDRA*</label>
<md-select id="registration-information-ndra"
name="ndra"
ng-model="vm.registration.code"
ng-class="{'validation-error': newForm.ndra.$error.required && newForm.$submitted}"
ng-required="vm.validation.ndra">
<md-option ng-repeat="code in vm.dropdowns.codes"
value="{{code}}">
{{code}}
</md-option>
</md-select>
</md-input-container>
vm.validation.ndra計算結果爲真實的,所以我知道這不是問題。如果我看VS工作選擇選項newForm.ndra的值,如newForm.submissionDate,我得到如下:
newForm.ndra: {"$viewValue":"p","$modelValue":"p","$validators":{},"$asyncValidators":{},"$parsers":[],"$formatters":[],"$viewChangeListeners":[],"$untouched":true,"$touched":false,"$pristine":true,"$dirty":false,"$valid":true,"$invalid":false,"$error":{},"$name":"ndra","$options":null}
註冊類型(驗證工作):
<md-input-container class="form-input-container padded-input md-block"
flex-gt-sm="">
<label>Type of Registration*</label>
<md-select id="registration-information-type"
name="registrationType"
ng-model="vm.registration.type"
ng-class="{'validation-error': newForm.registrationType.$error.required && newForm.$submitted}"
ng-required="vm.validation.registrationType">
<md-option ng-repeat="type in vm.dropdowns.types"
value="{{type}}">
{{type}}
</md-option>
</md-select>
</md-input-container>
{"$validators":{},"$asyncValidators":{},"$parsers":[],"$formatters":[],"$viewChangeListeners":[],"$untouched":true,"$touched":false,"$pristine":true,"$dirty":false,"$valid":false,"$invalid":true,"$error":{"required":true},"$name":"registrationType","$options":null}
您能否提供有關此問題的更多信息?你有缺省選擇還是空的選擇? – Malachi
您是否也可以顯示您列出的其他選項的標記? – Malachi
剛剛加了標記 –