PipeOptional

wrTruncate

Shorten a string and end it with an ellipsis.

Installation

Import the class. This entry point has no stylesheet.

import { Component } from '@angular/core';
import { WrTruncate } from 'ngwr/pipes';

@Component({ imports: [WrTruncate] })
export class MyComponent {}

Basic usage

A shorter string passes through unchanged.

{{ longText | wrTruncate: 24 }}  <!-- "Lorem ipsum dolor sit am…" -->
Lorem ipsum dolor sit am…

Custom ellipsis

The third argument replaces … and is added after the cut.

{{ longText | wrTruncate: 24 : ' [more]' }}
Lorem ipsum dolor sit am [more]

Playground

Lorem ipsum dolor sit am…

{{ text | wrTruncate: 24 : '…' }}

Customize

Text
Length
24
Ellipsis

API

NameDescriptionTypeDefault
wrTruncateCuts a string to length and appends ellipsis.(value: string | null | undefined, length = 80, ellipsis = '…') => string—

See also