<md-input-container flex-gt-xs>
<label translate>rule.type.title</label>
<md-select name="type" ng-required="true" ng-model="vm.model.type"
ng-change="vm.onRuleTypeChange(vm.model.type)">
<md-option ng-repeat="(key,value) in vm.types" ng-value="key">
<span translate>{{value}}</span>
</md-option>
</md-select>
<div ng-messages="form.type.$error">
<div ng-message-exp="['required']">
<span translate>rule.type.errors.required</span>
</div>
</div>
</md-input-container>
<md-input-container flex-gt-xs ng-if="vm.isRealTime(vm.model.type)">
<label translate>rule.result.title</label>
<md-select name="result" ng-required="true" ng-model="vm.model.result"
ng-model-options="{trackBy: '$value.id'}">
<md-option ng-repeat="result in vm.results" ng-value="result">
<span>{{result.name}}</span>
</md-option>
</md-select>
<div ng-messages="form.result.$error">
<div ng-message-exp="['required']">
<span translate>rule.result.errors.required</span>
</div>
</div>
</md-input-container>
这是我要问的页面的html。第一个容器用于文本输入,第二个用于选择框。
当我点击保存时,只有输入位置会出错,而不是组合框
但是当我点击那个boxx并且没有选择任何内容时保留该框时,它会给出错误
为什么?
很可能是因为
md-maxlength="50"
ng-minlength="2"
inpt文本具有该规则,因此它不能具有空值。但是selectbox呢?
答案 0 :(得分:0)
我做了这个并且有效
<md-input-container flex-gt-xs>
<label translate>rule.type.title</label>
<md-select name="type" ng-required="true" ng-model="vm.model.type"
ng-change="vm.onRuleTypeChange(vm.model.type)">
<md-option ng-repeat="(key,value) in vm.types" ng-value="key">
<span translate>{{value}}</span>
</md-option>
</md-select>
<div ng-messages="form.type.$error" ng-show="form.$submitted || form.type.$touched || form.type.$dirty ">
<div ng-message-exp="['required']" ng-hide="form.type.$valid">
<span translate>rule.type.errors.required</span>
</div>
</div>
</md-input-container>