InterviewHubPRO
Section Overview
Q55

Question 55 of 283

Part 2: HttpClient, RxJS Observables & Angular Elements (36 - 62)

19%
Angular & Signals (283 Qs)•Part 2: HttpClient, RxJS Observables & Angular Elements (36 - 62)

Explain how custom elements works internally?

Below are the steps in an order about custom elements functionality,

  1. App registers custom element with browser: Use the createCustomElement() function to convert a component into a class that can be registered with the browser as a custom element.
  2. App adds custom element to DOM: Add custom element just like a built-in HTML element directly into the DOM.
  3. Browser instantiate component based class: Browser creates an instance of the registered class and adds it to the DOM.
  4. Instance provides content with data binding and change detection: The content with in template is rendered using the component and DOM data. The flow chart of the custom elements functionality would be as follows,

CustomElement
CustomElement

Practical Code Example

text
// Custom Elements Internal Workflow:
// 1. Browser parser encounters <custom-element>
// 2. Custom Element Registry looks up constructor
// 3. Angular Elements creates ComponentRef and attaches Input/Output bindings
// 4. Component renders inside custom element host