填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

Pipe

Decorator that marks a class as pipe and supplies configuration metadata.

查看"说明"...

选项说明
name

在模板中绑定时使用的管道名

The pipe name to use in template bindings.

pure

true 时,该管道是纯管道,也就是说 transform() 方法只有在其输入参数变化时才会被调用。管道默认都是纯管道。

When true, the pipe is pure, meaning that the transform() method is invoked only when its input arguments change. Pipes are pure by default.

说明

A pipe class must implement the PipeTransform interface. For example, if the name is "myPipe", use a template binding expression such as the following:

{{ exp | myPipe }}
      
      {{ exp | myPipe }}
    

The result of the expression is passed to the pipe's transform() method.

A pipe must belong to an NgModule in order for it to be available to a template. To make it a member of an NgModule, list it in the declarations field of the NgModule metadata.

选项

在模板中绑定时使用的管道名

The pipe name to use in template bindings.

name: string
      
      name: string
    

true 时,该管道是纯管道,也就是说 transform() 方法只有在其输入参数变化时才会被调用。管道默认都是纯管道。

When true, the pipe is pure, meaning that the transform() method is invoked only when its input arguments change. Pipes are pure by default.

pure: boolean
      
      pure: boolean
    

如果该管道具有内部状态(也就是说,其结果会依赖内部状态,而不仅仅依赖参数),就要把 pure 设置为 false。 这种情况下,该管道会在每个变更检测周期中都被调用一次 —— 即使其参数没有发生任何变化。

If the pipe has internal state (that is, the result depends on state other than its arguments), set pure to false. In this case, the pipe is invoked on each change-detection cycle, even if the arguments have not changed.