0

我有一个材料设计选择,我正在尝试使用 ng-message 验证它

<md-input-container class="md-block" flex-gt-sm >
   <label>Payment method</label>
   <md-select name="paymentMethod"  ng-model="payment.paymentMethod" flex ng-change="paymentMethodChange(payment.paymentMethod)">
      <md-optgroup label="Payment Method">
      <md-option ng-repeat="item in PayArr track by $index" value="{{item}}">{{item}}</md-option>
   </md-select>
   <div ng-messages="editForm.paymentMethod.$error" >
      <div ng-message="required">payment method required</div>
   </div>
</md-input-container>

我的表单名称是editForm。我对输入框使用相同的场景,它工作正常。我不知道为什么它不适用于选择框。谢谢你们的支持

4

1 回答 1

2

您没有将required属性放入md-select.

<md-select name="paymentMethod" required  ng-model="payment.paymentMethod" flex ng-change="paymentMethodChange(payment.paymentMethod)">
      <md-optgroup label="Payment Method">
      <md-option ng-repeat="item in PayArr track by $index" value="{{item}}">{{item}}</md-option>
   </md-select>
于 2016-06-23T10:55:40.113 回答