Last active
September 22, 2016 05:32
-
-
Save neilmaledev/54c41b04c0fd4546eb930f97ec89987d to your computer and use it in GitHub Desktop.
i just modified the one that is here http://stackoverflow.com/questions/27064319/angularjs-limitto-using-html-tags. I added auto ellipsis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.filter('limitHtml', function() { | |
return function(text, limit) { | |
var changedString = String(text).replace(/<[^>]+>/gm, ''); | |
var length = changedString.length; | |
return changedString.length > limit ? changedString.substr(0, limit) + '...' : (changedString == 'null' ? '' : changedString); | |
}; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage:
<div ng-bind-html="news.description | limitHtml: 100">