admin管理员组文章数量:1391987
I'm using Renderer2 to render some custom elements in an Angular application. As each element is created, it is stored as a constant:
const myNewElement = this.renderer2.createElement('div');
When the time comes to remove this element, I am using removeChild. This has a parameter for the parent
of the node being removed:
removeChild(parent: any, oldChild: any, isHostElement?: boolean | undefined)
However if I set parent
to null, it seems to remove oldChild
from the DOM successfully and without throwing an error:
this.renderer2.removeChild(null, myNewElement); // Works!
Could this approach cause any potential issues? Should a parent element be specified, even if removeChild
works without it?
本文标签: angularUsing Renderer2 removeChild with parent set as nullStack Overflow
版权声明:本文标题:angular - Using Renderer2 removeChild with parent set as null - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744758250a2623592.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论