0

I want to use the limitTo filter in my angularJs application.

I have a div which displays a parsed html code as following :

<div ng-bind-html="o.description | filter:unsafe | filter:limitTo:50"></div>

but the limitTo filter didn't work.

How can I solve this problem ?

Edit :

due to @hadiJZ response I changed my div to this :

but still it doesn't work, when I tried to apply the limitTo filter on another div it worked, and this is an example :

<a href="#/offres/{{o.codeOffre}}">{{o.titre | limitTo:2}}</a>

the unsafe filter :

myApp.filter('unsafe', function($sce) {
  return function(val) {
    return $sce.trustAsHtml(val);
  };
});
Community
  • 1
  • 1
Renaud is Not Bill Gates
  • 1,684
  • 34
  • 105
  • 191

1 Answers1

1

try this. your syntax is incorrect. not to need use filter in here.

 <div ng-bind-html="o.description | unsafe | limitTo:50"></div>
Hadi J
  • 16,989
  • 4
  • 36
  • 62