I need to count chars of a text with and with out spaces.
This is my attemp, but count the text without only the first space.
<div style="max-width:80%; margin: 10px auto">
<section class="row" ng-app="">
<div class="col-lg-8">
<div class="panel panel-default">
<div class="panel-heading">Paste your text for <b>words count</b></div>
<div class="panel-body">
<textarea class="form-control" rows="10" ng-model="wordcounter"></textarea>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="panel panel-default">
<div class="panel-heading">Words and characters</div>
<ul class="list-group">
<li class="list-group-item">Characters (with space)<span class="badge">{{wordcounter.length}}</span></li>
<li class="list-group-item">Characters (no space)<span class="badge">{{wordcounter.replace(" ","").length}}</span></li>
</ul>
</div>
</div>
</section>
wordcounter.replace(/\s/g, '').length
will give you the length without spaces