I want to set the maxLength for an input element in Angular dynamically. Currently I am doing something like this:
<input type="text" [formControlName]="name"
[maxlength]="attribute.attributeName === AttributeName.FIRST_NAME ? 15 : attribute.attributeName === AttributeName.LAST_NAME ? 20 : 255">
but, this is not efficient in my opinion. I have a another scenario where I would need to check the condition for at least 15 different scenarios then set the maxLength.
I was wondering if there's any way to dynamically set it in the typescript file using @ViewChild?
try to grab following concept
for the HTML