禁用动态元素-angularjs

时间:2018-07-09 07:19:47

标签: html angularjs

我有这个静态元素

<sp-attachment-button ng-if="::data.canWrite &amp;&amp; data.canAttach"
                      id="disableElements" class="ng-scope">
</sp-attachment-button>

ng-if条件为true时,将动态添加一些子元素

<sp-attachment-button ng-if="::data.canWrite &amp;&amp; data.canAttach"
                      id="disableElements" class="ng-scope">
    <span class="file-upload-input">
        <input type="file" style="display: none" multiple="true"
               ng-file-select="data.onFileSelect($files)"
               class="sp-attachments-input">
        <button title="Add attachment"
                ng-click="attachmentHandler.openSelector($event)"
                class="panel-button sp-attachment-add btn btn-link"
                aria-label="Add attachment" role="button">
             <span class="glyphicon glyphicon-paperclip"></span>
        </button>
    </span>
</sp-attachment-button>

现在我需要在此处禁用button元素。因此,我尝试在<sp-attachment-button>元素中添加以下选项

1.disabled='disabled'
2.ng-disabled='true'

但是它不起作用。如何禁用button元素? 有什么建议吗?

Note:我只能看到<sp-attachment-button>元素。

1 个答案:

答案 0 :(得分:0)

如果您可以在该按钮上添加ID,则可以找到解决方法。

document.getElementsByClass("buttonId").disabled = true;