Text
truncateWords
Article previews cut at word boundaries.
Use it in your component
Standalone component
import { Component } from '@angular/core';
import { TruncateWordsPipe } from 'extra-pipe';
@Component({
standalone: true,
imports: [TruncateWordsPipe],
template: `{{ "Hello brave world" | truncateWords: 2 }}`,
})
export class ExampleComponent {
}
Template
{{ "Hello brave world" | truncateWords: 2 }}
Try it live.
The output below runs the packed library. Edit data, not code.
Use double quotes for text, or a number, array, object or null.
Ordered parameters: maximumWords, suffix. Locale is controlled separately.
Applied to the live output.
Live template data
readonly value = "Hello brave world";
readonly parameter0 = 2;
{{ value | truncateWords: parameter0: undefined: "en-US" }}
Rendered output
Hello brave…