How to set value in 2 way binding in angular with a function

Discussão em 'Angular' iniciado por user1938143, Fevereiro 3, 2025.

  1. user1938143

    user1938143 Guest

    I have a problem that how can I set a value in 2 way binding with a function.

    the code looks like that:

    <app-charge-station-modification-sort-order
    [(canAddMore)]="setCanAddMoreSortOrder(eForm.controls.sO.value)"
    [index]="index"
    [formGroup]="form"
    [selectedValues]="sOValues"
    controlName="sO"
    ></app-charge-station-modification-sort-order>


    and ts file:

    public setCanAddMoreSO(sO: number):boolean{
    return isNaN(sortOrder) ? false : true;
    }


    but I got this error:


    Unhandled Promise rejection: Errors during JIT compilation of template for xxx

    Error: Unexpected token '='
    ​

    any solutions??

    Continue reading...

Compartilhe esta Página