You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
659 B
TypeScript
28 lines
659 B
TypeScript
import { Pipe, PipeTransform } from '@angular/core';
|
|
|
|
@Pipe({
|
|
name: 'turncate'
|
|
})
|
|
export class TurncatePipe implements PipeTransform {
|
|
|
|
transform(value: any, args?: any): any {
|
|
console.log("args" + args);
|
|
|
|
let limit = args.length > 0 ? parseInt(args[0], 10) : 10;
|
|
let trail = args.length > 1 ? args[1] : '...';
|
|
|
|
console.log("limit" + limit);
|
|
|
|
console.log("parseInt(args[0], 10)" + parseInt(args[0], 10));
|
|
console.log("trail" + trail);
|
|
console.log("limit" + limit);
|
|
console.log("parseInt(args[0], 10)" + parseInt(args[0], 10));
|
|
|
|
return value.length > limit ? value.substring(0, limit) + trail : value; }
|
|
|
|
|
|
|
|
|
|
|
|
}
|