Angular: boolean property isn't passed correctly

Discussão em 'Angular' iniciado por Tamás Bárász, Dezembro 17, 2024.

  1. I have a component with a boolean property, with default value true When I try to use it with the property explicitly set to false, it still gets a true value.

    select.component.ts:

    @Component({
    selector: 'my-select',
    standalone: true,
    })
    export class MySelect {
    @Input()
    sortOptionsByLabel: boolean = true
    someProcess(){
    console.log(this.sortOptionsByLabel)
    }
    }


    another.component.html:

    <my-select [sortOptionsByLabel]="false" />


    And I get true in the console! Why? What am I doing wrong?

    Continue reading...

Compartilhe esta Página