【问题标题】:How to add disabled attribute to input tag with ngTagsInput?如何使用 ngTagsInput 向输入标签添加禁用属性?
【发布时间】:2014-11-04 05:56:26
【问题描述】:

我有一个自定义指令,用于管理通过我的网站访问的用户。我用它来为 html 标签添加一个 'disabled="disabled"' 属性。

但是,当我尝试将它与标签输入一起使用时,它不起作用。我猜这是因为 ngTagsInput 使用它自己的标签输入指令。

我已阅读文档,但找不到我正在寻找的解决方案。

这是我的代码:

HTML:

<div access-level="Admin">
   <tags-input ng-model="tags" on-tag-added="addNewTag($tag)" on-tag-removed="removeTag($tag)">
       <auto-complete source="loadTags($query)" min-length="0"></auto-complete>
   </tags-input>
</div>

有什么解决办法吗?

谢谢。

【问题讨论】:

    标签: html angularjs ng-tags-input


    【解决方案1】:

    目前不受支持,但看起来将在下一个主要版本 (2.3.0) 中: https://github.com/mbenford/ngTagsInput/issues/102

    编辑: 2.3.0 出来了;详情见以下链接https://github.com/mbenford/ngTagsInput/blob/master/CHANGELOG.md#features

    【讨论】:

      【解决方案2】:

      我在 2.3.0 版本中找不到这个选项,但至少他们启用了常规禁用属性。 我所做的隐藏删除按钮和“添加标签”输入框,是在 CSS 中添加一些规则。

      tags-input[disabled] .remove-button {
          display: none;
      }
      tags-input[disabled] input.input {
          display: none;
      }
      

      可能有更好的方法来做到这一点,这是我能找到的最快的方法。

      【讨论】:

        猜你喜欢
        • 2017-08-06
        • 2014-12-17
        • 2011-04-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-09-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多