I am using pretty nice plugin which provides tags input directive for AngularJS.
I'm using the parameter onTagAdding to check tag's value before it will be added to input.
on-tag-adding="{expression}"
So, as documentation says:
Expression to evaluate that will be invoked before adding a new tag. The new tag is available as $tag. This method must return either true or false. If false, the tag will not be added.
So here is an live example.
$scope.checkTag = function(tag) {
angular.forEach($scope.forbiddenTags, function(e){
if (e.text === tag.text) {
alert('Tag is forbidden')
return false;
}
})
alert('Execution is continuing');
}
I'm expecting that if entered value matches one for those tags from $scope.forbiddenTags array, then false should be returned and function's execution should be stopped, but it works not like i am expecting =). I have tried just with return but it doesn't work either.
Any help and suggestions will be appreciated! Thanks in advance!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire