I am trying to limit the characters i see on my angular js app. Currently i am using:
You can use this without function if you are using sanitize filter
<p ng-bind-html="message | limitTo: 150 | sanitize"></p>
since you use ng-bind-html
you also need $sce
, so my advice do it in your controller. Like so
Ctrl.$inject= ['$sce', '$filter', '$scope'];
Function Ctrl($sce, $filter, $scope) {
$scope.content= $filter('limitTo')(dataWithHtml, 100, 0);
$scope.content= $sce.trustAsHtml($scope.content);
}
on html you can use like so:
<p ng-bind-html="content"></p>
in this case I assume your original data is dataWithHtml
, 100 is the limit number, 0 is the starting point. More details please refer to official documentations.