向输入标签添加禁用属性

向输入标签添加禁用属性

本文介绍了如何使用 ngTagsInput 向输入标签添加禁用属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

这是我的代码:

HTML:

<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>

有什么办法可以解决这个问题吗?

谢谢.

解决方案

我在 2.3.0 版本中找不到这个选项,但至少他们启用了常规的禁用属性.我为隐藏删除按钮和添加标签"输入框所做的工作是在 CSS 中添加了几条规则.

tags-input[disabled] .remove-button {显示:无;}标签输入[禁用] input.input {显示:无;}

可能有更好的方法,这是我能找到的最快的方法.

I have a custom directive that I use to manage user access through my website. I use this to add a 'disabled="disabled"' attribute to html tags.

However, when I try to use this with tag-input, it doesn't work. I'm guess this is down to that fact that ngTagsInput uses it's own directive for tags-input.

I have read the documentation and cannot find a solution to what I am looking for.

Here is my code:

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>

Is there any work around for this?

Thanks.

解决方案

I could not find this option in the release 2.3.0, but at least they have enabled the regular disabled attribute.What I have done to hide the remove button and the "Add a tag" input box, was to add a couple of rules in the CSS.

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

Probably there is a better way to do it, this was the fastest I could find.

这篇关于如何使用 ngTagsInput 向输入标签添加禁用属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 10:14