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
This commit is contained in:
parent
4ac55ca676
commit
bf505ad707
@ -5,12 +5,12 @@
|
||||
* 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: any) {
|
||||
transform(value: string) {
|
||||
return value.split(' ').slice(0, 2).join(' ') + '...';
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,12 @@
|
||||
* 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: any, length: number, symbol: string) {
|
||||
transform(value: string, length: number, symbol: string) {
|
||||
return value.split(' ').slice(0, length).join(' ') + symbol;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user