I am reading educational data from facebook and showing it to my page directly. I find some string too long so i want to put ... after certain number of character in angularjs.
ex
jeevan sadhana english medium high school 08
to
jeevan sadha..
I am reading educational data from facebook and showing it to my page directly. I find some string too long so i want to put ... after certain number of character in angularjs.
ex
jeevan sadhana english medium high school 08
to
jeevan sadha..
There are two possible solutions.
text-overflow: ellipsis; along with overflow: hidden;. Obviously, your element will have to be fixed width.Create filter in angular code.
Working http://jsfiddle.net/tUyyx/
Use filter code give in fiddle.
Then filter your content like :
{{ name | truncate : 25}}
If you want to add ellipses after n number of lines then we can do this using Jquery.dotdot plugin Check this link Adding ellipses after n-bumber of lines in AngularJs
maxLength = 10;
str = str.length > maxLength ? str.substr(0, maxLength) + '...' : str;
$scope variable though), because it could be reused throughout the scope of the controller and made dynamic if one were to turn this piece of code into a filter and pass the length into said filter. That way, you wouldn't loose the original string. However, should one want to do that, angular-truncate is probably the best bet as suggested by Zopieux.