angulartextareaprimengautoresize

autoresize in angular primeng throw error


when I try to use the autoresize attribut, i have one error: Type 'string' is not assignable to type 'boolean'

the template code is : <textarea [rows]="5" [cols]="30" id="float-input3" pInputTextarea autoResize="true"></textarea>

I use this attribute like in the documentation, i don’t know what is not working.

I have already try to use autoResize="autoResize" but I have the same error.

the documentation https://www.primefaces.org/primeng/showcase/#/inputtextarea

Do you know what is not working or what I am not doing correctly ?

I use Primeng 11.2.0 and Angular 11.

Thanks for your help


Solution

  • Pretty sure you need to add a new public property to your component:

    public autoResize: boolean = true;
    

    ...and then bind it into the template like:

    <textarea ... [autoResize]="autoResize"></textarea>
    

    In your examples you didn't have the [ ] around the property. Angular was getting confused as to whether you wanted to pass "true" as a string or true as a boolean. When it is explicitly defined in the component with :boolean, angular can be assured of what the type is.