In my form, I have two text fields that are linked to <span>
elements to display the total number of characters inputted.
I have implemented a condition using ng-if
.
However, I want to display the remaining characters text only when the respective textarea
is in a focused
state.
https://i.sstatic.net/ib5Gt.png
<textarea ng-model="goal.goal_name"
required ng-focus="openFullcreateGoalController()" maxlength="90" placeholder="Write your title here"></textarea>
<span ng-if="goal.goal_name && !goal.goal_description">{{90 - goal.goal_name.length}}characters left</span>
<textarea msd-elastic ng-model="goal.goal_description" required placeholder="Add description" maxlength="140"></textarea>
<span ng-if="goal.goal_description">{{90 - goal.goal_description.length}}characters left</span>
My code currently only displays the remaining characters if the other field is empty.