Substring in Ionic

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!:slightly_smiling:

Try break-word:normal for the CSS of your <p>

i’m sorry but that’s not working bro.

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));


Oh, I misunderstood your question.
Thaught you just wanted to break the line.

you can use the LimiTo filter :

in your case : <p>{{list.description | limitTo:number}}</p>

and you can calculate your number with

1 Like

Thanks man! i really appreciate it!