This is angular app, I want to apply css class based on condition that char length of variable is greater than 128 char. I was inspired by this post enter link description here. As shown below in the code snippets, I am trying to dynamically apply style based on condition that charlen value is within or outside 128. Please I am new to Angular and I am npot aware of many concepts, thnak you for suggestions.
template.html
<input [ngClass] = "(charlen <128)?'class1':'class2' />
template.ts
str:String;
charlen:Number;
ngInit () {
str="this is not 128 char";
charlen = str.length;
}
template.css
.class1 {
color:red;
}
.class2 {
color:blue;
}