只允许一个在angularJS标签输入框标记 [英] Allow only one tag in tag input box in angularJS

查看:261
本文介绍了只允许一个在angularJS标签输入框标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作角度,我创建了一个自动完成标签框。它的工作完美的,但需要量是,用户只能选择一个标签,但在我的情况越来越多选择的每日新闻。我的code如下。

 < D​​IV>
         <标签输入NG模型=标签显示属性=姓名>         <自动完成源=loadTags($查询)占位符=开始输入最小长度=0去抖延迟=0>< /自动完成>         < /标签输入>         &所述p为H.;型号:{{代码}}&下; / P>        <按钮类=按钮NG点击=GetAllProjectByKeyId(searchKeyword.key)>搜索和LT; /按钮>
    < / DIV>


解决方案

在文档页面: HTTP ://mbenford.github.io/ngTagsInput/documentation/api

您可以看到你可以设定最高-标签属性:

 <标签输入NG模型=标签显示属性=姓名MAX-标签=1>

I am working in angular, I have created a autocomplete tag box. its working perfect but requirment is, user can select only one tag but in my case multiple tages are getting selected. My code is below.

 <div>
         <tags-input ng-model="tags" display-property="name">

         <auto-complete source="loadTags($query)" placeholder="Start typing"  min-length="0" debounce-delay="0"></auto-complete>

         </tags-input>

         <p>Model: {{tags}}</p>

        <button class="Button" ng-click="GetAllProjectByKeyId(searchKeyword.key)">Search</button>
    </div> 

解决方案

On the documentation page: http://mbenford.github.io/ngTagsInput/documentation/api

You can see you can set a max-tags property:

<tags-input ng-model="tags" display-property="name" max-tags="1">

这篇关于只允许一个在angularJS标签输入框标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆