Hi, i have text like this.
“This word is very long. how to cut this sentence by word, not by character?”
For example i want to cut the text after word “cut”
“This word is very long. how to cut”
in php, i found this answer using substring. but how to do in ionic?
that text I get from database and i call that like this:
<div class="row" ng-repeat="list in list"> <p>{{list.description}}</p> </div>
Any help would be thankful!
JC_cap
March 9, 2016, 1:27pm
2
Try break-word:normal for the CSS of your <p>
i’m sorry but that’s not working bro.
Geogo
March 9, 2016, 2:22pm
4
Try modifying your string in a controller with something similar to this:
var maxLength = (some character count that’s near your cut-off point );
var str = “your string here ”;
str = str.substring(0, str.indexOf(" ", maxLength));
2 Likes
JC_cap
March 9, 2016, 2:24pm
5
Oh, I misunderstood your question.
Thaught you just wanted to break the line.
you can use the LimiTo filter :
https://docs.angularjs.org/api/ng/filter/limitTo
in your case : <p>{{list.description | limitTo:number}}</p>
and you can calculate your number with String.search()
http://www.w3schools.com/jsref/jsref_search.asp
1 Like
Thanks man! i really appreciate it!