最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ngTagsInput in Angular - Stack Overflow

programmeradmin1浏览0评论

I am using tagsInput Api in Angular

here is link

i want to add a tag on space. but it is not working.

here is my code

<tags-input  ng-model="emails" placeholder="Add an Email"  [add-on-space="true"]>

Also i want to add Email validator in tags . i have no idea.

Any idea how to do this ?

Thanks

I am using tagsInput Api in Angular

here is link

i want to add a tag on space. but it is not working.

here is my code

<tags-input  ng-model="emails" placeholder="Add an Email"  [add-on-space="true"]>

Also i want to add Email validator in tags . i have no idea.

Any idea how to do this ?

Thanks

Share Improve this question edited Jan 7, 2015 at 6:25 Colin Brock 21.6k9 gold badges49 silver badges62 bronze badges asked Jan 7, 2015 at 6:04 Hitu BansalHitu Bansal 3,13712 gold badges55 silver badges89 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 12

Try dropping the square brackets from your attribute. e.g.:

<tags-input  ng-model="emails" placeholder="Add an Email" add-on-space="true">

Square brackets are just used in their documentation to indicate the ones that are optional. In its current form, your HTML isn't valid.

To validate emails, try the "allowed-tags-pattern" attribute with regex, as below:

<tags-input ng-model="emails" placeholder="Add an Email" add-on-space="true" allowed-tags-pattern="^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$">

Hope this helps.

发布评论

评论列表(0)

  1. 暂无评论