Pete Bacon Darwin bf505ad707 docs(core): tighten up PipeTransform example types (#42240)
The example was using `any` type but then assuming that the value was a string.

Fixes #42239

PR Close #42240
2021-05-24 17:08:34 +00:00

17 lines
479 B
TypeScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// #docregion
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({name: 'truncate'})
export class TruncatePipe implements PipeTransform {
transform(value: string, length: number, symbol: string) {
return value.split(' ').slice(0, length).join(' ') + symbol;
}
}