I need some assistance here, I am unable to pass a variable to the @Input variable of my Elements tag. If I hard code a caller-id = "123456" inside the tag it works with no issues; however if I try and pass the caller id from the Angular component as a variable it does not recognize it. I am basically trying to retrieve the userId of the component and pass it to the elements app to do what it needs to do with the userId. Any help would be appreciated, thanks.
Angular Elements App .ts
export class AppComponent implements AfterContentInit {
@Input() userId: string = "";
@Input() userId2: string = "";
ngAfterContentInit() {
console.log(this.userId);
console.log(this.userId2);
}}
app.module.ts of Angular Elements App
import { BrowserModule } from '@angular/platform-browser';
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import {createCustomElement} from '@angular/elements';
import { Injector } from '@angular/core';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
],
providers: [],
entryComponents: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
bootstrap: [AppComponent]
})
export class AppModule {
constructor(injector: Injector) {
const custom = createCustomElement(AppComponent, {injector});
customElements.define('elements-app', custom)
}
ngDoBootstrap() {
}
}
Current Angular Component that is implementing the angular elements tag from .js
.ts file of component implementing the Elements App
constructor() {
this.userId = "123456"
}
HTML file of component implement the Elements app
*does not work*- <elements-app user-id=userId></elements-app
*works*- <elements-app user-id="123456"></elements-app
app.module.ts of the app consuming the angular elements .js file tag
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
HttpClientModule
],
providers: [HttpClientModule, HttpClient],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
bootstrap: [AppComponent]
})
export class AppModule { }