I'm trying to make a character counter that mimics a phone for sms. I've got it counting characters, spaces, and line breaks, however my counters differ. With line breaks, it decrements by 1 in the count for message.length, but does for more than one in the maxlength. I'm thinking that more spaces are added in when indented, but not sure how to get the message.length
set the same as maxlength
.
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app>
<textarea ng-model="message" ng-trim="false" maxlength="160"></textarea>
<span>{{160 - message.length}} left</span>
</body>
Also this answer doesn't actually work for this (it counts spaces and line breaks as 1): angularjs text area character counter