How to add disabled attribute to input tag with ngTagsInput?

那年仲夏 提交于 2019-12-13 01:50:20

问题


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.


回答1:


It's currently unsupported, but looks like will be in the next major version (2.3.0): https://github.com/mbenford/ngTagsInput/issues/102

Edit: 2.3.0 is out; see following link for details https://github.com/mbenford/ngTagsInput/blob/master/CHANGELOG.md#features




回答2:


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.



来源:https://stackoverflow.com/questions/25767878/how-to-add-disabled-attribute-to-input-tag-with-ngtagsinput

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!