0

I want to show summary of text as per window size in Angular.Means to show a fixed part of whole paragraph as per window size.
I was using custom pipes to manually fixed the size of content visible on screen

<p> {{ text | summary:50 }}

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'summary'
 })
 export class SummaryPipe implements PipeTransform {

transform(value: string, limit?: number) {
    if (!value) { return null; }

    const actuallimit = (limit) ? limit : 50;
    return value.substr(0, actuallimit) + '...';
}
}

So instead of this fixed parameter (like 50 ) , I want to pass parameter based on window size.

How can I do this ?

1 Answers1

0

You need to watch the window size to accomplish this. Check this for more details: https://stackoverflow.com/a/45350792/5346095

Peter
  • 10,492
  • 21
  • 82
  • 132