PipeTransform

interface PipeTransform { transform(value: any, ...args: any[]): any }

方法

transform(value: any, ...args: any[]): any

参数

value

Type: any.

args

Type: any[].

返回值

any

使用说明

Example

例子

The RepeatPipe below repeats the value as many times as indicated by the first argument:

下面的 RepeatPipe 会把第一个参数指定的值(value)重复很多次(times):

import {Pipe, PipeTransform} from '@angular/core'; @Pipe({name: 'repeat'}) export class RepeatPipe implements PipeTransform { transform(value: any, times: number) { return value.repeat(times); } }

Invoking {{ 'ok' | repeat:3 }} in a template produces okokok.

在模板中调用 {{ 'ok' | repeat:3 }} 的结果是 okokok