【发布时间】:2019-04-28 10:04:05
【问题描述】:
我正在尝试使用选项多个选项来验证 ui-select。 但是没有角度验证有效。甚至创建自定义验证。那总是返回无效。
仅删除所有验证工作的(多个)选项(必需和自定义)
<ui-select multiple ng-model="Model.Test" close-on-select="false"
search-enabled="true" required custom-validation>
<ui-select-match allow-clear="true">{{$item.Name}}</ui-select-match>
<ui-select-choices repeat="item in Items | filter:$select.search">
<div ng-bind-html="item.Name | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
app.directive('customValidation', function () {
return {
require: 'ngModel',
link: function (scope, elm, attrs, ctrl) {
ctrl.$validators.customValidation = function (modelValue, viewValue) {
return false;
};
}
};
});
【问题讨论】:
-
当询问由您的代码引起的问题时,如果您提供人们可以用来重现问题的代码,您将获得更好的答案。见How to create a Minimal, Complete, and Verifiable example。
-
您的 codepen 与问题中的代码不匹配。你没有提到你正在使用
jcs-autovalidate.js。