angular-filter icon indicating copy to clipboard operation
angular-filter copied to clipboard

ltrim and rtrim

Open MaccerC opened this issue 6 years ago • 1 comments

Is it possible to trim a number of characters and not only a certain part of a string?

MaccerC avatar May 13 '18 14:05 MaccerC

I don't know if you still care, but I managed to trim a number of characters with the truncate and reverse filters.

$scope.message = 'Hello World'
<p>{{message| reverse | truncate: message.length - 7 | reverse}}</p>

results in "orld", which is the same as removing 7 characters from the left. If you want to remove characters from the right, you can just use truncate.

<p>{{message | truncate: message.length - 7}}</p>

results in "Hell"

RSchneyer avatar Jun 21 '18 18:06 RSchneyer