简体   繁体   English

document.getElementById()在uib-tab中不起作用

[英]document.getElementById() not working inside uib-tab

When my DOM element is outside the uib-tab ,then it is working fine 当我的DOM元素在uib-tab ,则工作正常

Html: HTML:

<input type="file" id="clickMe"/>
   <uib-tab>

   </uib-tab>

angular controller : 角度控制器

console.log(document.getElementById('clickMe'));

And giving me the desired result. 并给我想要的结果。

But when i am putting my DOM element inside the uib-tab , then 但是当我将DOM element放入uib-tab

Html: HTML:

<uib-tab>
    <input type="file" id="clickMe"/>
</uib-tab>

controller: 控制器:

console.log(document.getElementById('clickMe'));

giving me null . 给我null

Please Help. 请帮忙。

Guess you are trying to console while page is still not rendered completely . 猜猜您试图在页面尚未完全呈现时进行控制台。 You should try wrap it with $timeout , which equal with document.ready . 您应该尝试用$timeout包装它,它等于document.ready

refer this plunker . 推荐这个笨蛋

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM