Reputation: 1454
I have below code to post a tags list , when I am typing a list of numbers like 3453453,345345,345345,567567676 in my tags input
angular posts only one number from the list:
HTML
<tags-input placeholder="{{placeholder}}"
min-length="1"
max-length="11"
ng-class="{'read-input': tags.length > 6}"
allowed-tags-pattern="^[0-9]+$" max-tags="6" ng-model="tags"></tags-input>
<input type="hidden" ng-model="post.phones">
Angular code :
$scope.$watch('tags', function (tags) {
if (angular.isArray(tags)) {
$scope.post.phones = tags.map(function (tags) {
return parseInt(tags.text, 10);
});
} else {
$scope.post.phones = [];
}
});
Upvotes: 0
Views: 83
Reputation: 17289
may be add model to tags-input resolve your problem.
<tags-input
ng-model="post.phones"
placeholder="{{placeholder}}"
min-length="1"
max-length="11"
ng-class="{'read-input': tags.length > 6}"
allowed-tags-pattern="^[0-9]+$"
max-tags="6"></tags-input>
Upvotes: 1