Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including spaces in Angular characterLimit

Tags:

angularjs

I am implementing a character countdown (similar to Twitter's) and am finding that the character count isn't counting spaces. How do I modify the following to include spaces as well as characters?

<span class="characterLimit" ng:bind="140 - result.shortName.length"></span>
like image 575
KEB Avatar asked Jul 04 '13 15:07

KEB


1 Answers

By default angular trims anything bound using ng-model in later versions (1.1.x as far as I know) you can turn off this behaviour using ng-trim="false":

<input type="text" ng-model="tweet" ng-trim="false">

I made a demo of this here

like image 70
Derek Ekins Avatar answered Nov 04 '22 11:11

Derek Ekins