I have created an custom element in angular 7 using CUSTOM_ELEMENTS_SCHEMA. My app.module.ts is as follows:
export class AppModule {
constructor(private injector: Injector) {}
ngDoBootstrap() {
this.registerCustomElements();
}
registerCustomElements() {
const HeaderElement = createCustomElement(AppComponent, {
injector: this.injector
});
const FooterElement = createCustomElement(BcAngFooterComponent, {
injector: this.injector
});
customElements.define("header-element", HeaderElement);
customElements.define("footer-element", FooterElement);
}
}
I have referenced these custom elements in my app.component.html as below:
<footer-element footer-data="footerInputData"></footer-element>
This footerInputData is referenced in my app.component.ts file as a string.
export class AppComponent {
footerInputData: any = {title: "Page Title"};
}
Inside the HTML of my custom element, I have used interpolation to display the data passed to it as an input.
<div class="nav-list-wrap">
{{footerData}}
</div>
When the page loads, I do not see the object displayed. Instead, it is showing 'footerInputData'.
How to make my custom element fetch the data from my app.component.ts file, instead of displaying the data as a sting.
Also, can JSON objects be passed to my custom element?