I set strictTemplates:true
and use in a HTML template the following
<textarea matInput matAutosizeMaxRows="4" matTextareaAutosize="true"
I receive from the compiler
error TS2322: Type 'string' is not assignable to type 'number'.
error TS2322: Type 'string' is not assignable to type 'boolean'.
But how to set it properly in the HTML-Templates (to avoid the error)?
Full modelink. If the fullTemplateTypeCheck flag is set to true , Angular is more aggressive in its type-checking within templates.
To be more precise, Angular creates Type Check Blocks (TCBs) based on the component template. Basically, a Type Check Block is a block of TypeScript code which can be inlined into source files, and when type checked by the TypeScript compiler will give us information about any typing errors in template expressions.
To eliminate the risk of script injection attacks, Angular does not support the <script> element in templates. Angular ignores the <script> tag and outputs a warning to the browser console.
Wrap the property name in brackets. If you leave the brackets, the values will be interpreted as strings. With brackets, the values are interpreted as TypeScript, and are therefore typed properly.
<textarea matInput [matAutosizeMaxRows]="4" [matTextareaAutosize]="true"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With