After reading this discussion regarding a web-component I created:
<my-vue-web-comp [userId]="1" id="my-component"></my-vue-web-comp>
The component functions properly in Angular. How can I determine when the web component has been mounted in the DOM?
In this section of code, I keep getting a null value:
ngAfterViewInit() {
const myComponent = document.getElementById('my-component')
console.log(myComponent) //null
}
In this snippet of code, I am able to get my component, but I have to wait 0.5 seconds:
ngAfterViewInit() {
setTimeout(
function() {
const myComponent = document.getElementById('my-component')
console.log(myComponent) //not null
}, 500)
}
Is there a tool or event that can be used to detect when a web-component is mounted in the DOM?