Reputation: 105
I have a long tittle below image but I need to trim it and the image is not properly aligned how do I make it appear clear while viewing
Upvotes: 1
Views: 1008
Reputation: 3258
Best way to trim text from last is to create your custom pipe and use it.
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'trimLast'
})
export class TrimLastPipe implements PipeTransform {
transform(value: string, args: string[]): string {
const limit = args.length > 0 ? parseInt(args[0], 10) : 20;
const trail = args.length > 1 ? args[1] : '...';
return value.length > limit ? value.substring(0, limit) + trail : value;
}
}
and then register this custom pipe to module. you can use it in entire application.
Upvotes: 3
Reputation: 5265
CSS
.wrap-text {
width: 250px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
HTML
<h4 class="wrap-text">Sachin Ramesh Tendulkar is a former Indian international cricketer and a former captain of the Indian national team.</h4>
Upvotes: 2