I want to limit some content(which it's 50+ words approx) from my API to 15 words , I am trying to make a Pipe but isn't work, the pipes I've found are limit but only characters not words..
I use this:
@Pipe({
name: 'limitToPipe'
})
export class LimitToPipePipe implements PipeTransform {
transform(value: string, limit: number): string {
let trail = '...';
return value.length > limit ? value.substring(0, limit) + trail : value;
}
}
as I said before, that is not what I want, cause I need to return 15 words and not characters.
can someone help me to do this ? I'm wasted from morning to night trying to do this.