Skip to content

Input transform not working with Angular Elements #50708

Closed

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

Activity

  1. added
    area: elements
    on Jun 14, 2023
  2. added this to the needsTriage milestone on Jun 14, 2023
  3. self-assigned this
    on Jun 14, 2023
  4. added a commit that references this issue on Jun 22, 2023
    6e05186
  5. added a commit that references this issue on Jun 22, 2023
    e1bbe47
  6. angular-automatic-lock-bot commented on Jul 23, 2023

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  7. locked and limited conversation to collaborators on Jul 23, 2023
  8. added a commit that references this issue on Jan 23, 2024
    25aa296
  9. added a commit that references this issue on Jun 6, 2024
    d64864e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: elementsstate: has PR

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions