Skip to content

Input transform not working with Angular Elements #50708

@ManuelRauber

Description

@ManuelRauber

Which @angular/* package(s) are the source of the bug?

core, elements

Is this a regression?

No

Description

When a component is transformed to a Web Component, the new Input transform does not work. It's not being executed. Setting the input itself works.

In my opinion it should work, because @Input() is also being used to set inputs for Angular Elements.

Please check the link for the whole code sample.

Code sample

function doTransform(input: unknown): string {
console.log('doTransform', input);
return I was transformed! ${input};
}

@component({
standalone: true,
template: 'Hello from a Web Component! {{ someInput }}',
styles: [:host {display: block}]
})
export class MyAngularElement {
@input({ transform: doTransform }) someInput: string = '';
}

@component({
selector: 'my-app',
standalone: true,
imports: [CommonModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: <my-web-component some-input="No Binding" /> <my-web-component [someInput]="'Binding'" />,
})
export class App implements OnInit {
private readonly injector = inject(Injector);
ngOnInit(): void {
const customElement = createCustomElement(MyAngularElement, {
injector: this.injector,
});
customElements.define('my-web-component', customElement);
}
}

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-2tbaav?file=src%2Fmain.ts

Please provide the exception or error you saw

It's not working at all. :) No error in the console.

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 16.1.0
Node: 18.16.0
Package Manager: npm 9.5.1
OS: darwin arm64

Angular: 16.1.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... elements, forms, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1601.0
@angular-devkit/build-angular   16.1.0
@angular-devkit/core            16.1.0
@angular-devkit/schematics      16.1.0
@schematics/angular             16.1.0
rxjs                            7.5.5
typescript                      5.0.4

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions