ng-message 不适用于 select 个盒子
ng-message doesn't work for select boxes
我有一个 material 设计 select 我正在尝试使用 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。我对输入框使用了相同的场景,并且效果很好。我不明白为什么它对 select 框不起作用。感谢大家的支持
您没有将 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>
我有一个 material 设计 select 我正在尝试使用 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。我对输入框使用了相同的场景,并且效果很好。我不明白为什么它对 select 框不起作用。感谢大家的支持
您没有将 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>