• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

68
Views
Detect mounting of web-component in DOM

I read this thread created web-component:

<my-vue-web-comp [userId]="1" id="my-component"></my-vue-web-comp>

It works fine in Angular. How can I detect when web component was mounted in DOM?

In this code I get null:

ngAfterViewInit() {
  const myComponent = document.getElementById('my-component')
  console.log(myComponent) //null
}

In this code I get my component, but I should wait 0.5 sec:

ngAfterViewInit() {
        setTimeout(
            function() {
                const myComponent = document.getElementById('my-component')
                console.log(myComponent) //not null                
            }, 500)
    }

Is there any tool (event) to detect mounting of web-component in DOM ?

about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Need to add connectedCallback() from the docs:

Vue.customElement('web-component', (MyWebComponent as any).options, { connectedCallback() {
      console.info('connectedCallback', this)
    }})
about 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error