我需要在自动完成中进行验证,例如
- 最小长度
- 最长长度
- 芯片总数
我力求找到一种正确的方法来验证所有这些验证我的 HTML 是
<md-chips md-on-add="selectedGroups.add($chip)" ng-focus="userTag"
ng-model="selectedGroups" is="tagSelect" md-autocomplete-snap
md-require-match="true" md-max-chips="3" maxlength="10">
<md-autocomplete
md-search-text="searchText"
md-items="item in queryGroups(searchText)"
md-item-text="item"
md-autoselect="true" md-select-on-match="true"
md-no-cache="true"
md-require-match="true"
md-input-name="autocompleteField"
md-input-minlength="2"
md-input-maxlength="5"
>
<span
md-highlight-text="searchText">{{item}}</span>
<div ng-messages="searchForm.autocompleteField.$error" ng-if="searchForm.autocompleteField.$touched">
<div ng-message="required">You <b>must</b> have a favorite state.</div>
<div ng-message="minlength">Your entry is not long enough.</div>
<div ng-message="maxlength">Your entry is too long.</div>
</div>
</md-autocomplete>
<md-chip-template
ng-maxlength="2" md-max-chips="5" required> <span>{{$chip}}</span>
</md-chip-template> </md-chips>
我的js是
var allGroups = ['one','two','three' ];
$scope.queryGroups = function(search) {
var firstPass = $filter('filter')($scope.allGroups, search);
return firstPass.filter(function(item) {
return $scope.selectedGroups.indexOf(item) === -1;
console.log(item)
});
};
请帮我