Reputation: 89
For example I want to add custom validation where addedValue<20, how to implemenet it?
<tags-input ng-model="numbers"
placeholder="Add a number"
min-length="1"
max-length="3"
allowed-tags-pattern="^[0-9]+$"
onTagAdded="$tag<20"></tags-input>
this is code I use.
Upvotes: 1
Views: 3159
Reputation: 5825
You could use the on-tag-adding
attribute to check if it's a valid tag:
<tags-input ng-model="numbers"
placeholder="Add a number"
min-length="1"
max-length="3"
on-tag-adding="checkTag($tag)">
</tags-input>
In your controller:
$scope.checkTag = function(tag) {
// check if its a valid number and smaller than 20
return !isNaN(tag.text) && +tag.text < 20;
}
Upvotes: 8