assign Angular signal-based inputs dynamically

Discussão em 'Angular' iniciado por Iris Dreizen, Dezembro 1, 2024.

  1. Iris Dreizen

    Iris Dreizen Guest

    I'm encountering an issue when trying to update inputs on a component loaded into an Angular CDK overlay.

    Here's my component:

    TypeScript
    @Component({
    selector: 'my-component',
    templateUrl: '..',
    imports: [...],
    })
    export class MyComponent {
    readonly myInput = input.required<MyInputInterface>();

    ngOnInit() {
    console.log(this.myInput());
    }
    }


    I'm using Object.assign(componentRef.instance, context) to pass data to the component when creating the overlay. However, I get an error stating that this.myInput is not a function.

    The component works correctly when used with a parent component and regular input binding. When debugging, I can see that myInput does have a value within the overlay component.

    Could Object.assign be causing problems with the input setter or Angular's change detection within the overlay?

    Continue reading...

Compartilhe esta Página