Pipe
本裝飾器用於將類別標記為管道並提供配置元資料。
Decorator that marks a class as pipe and supplies configuration metadata.
選項 | 說明 |
---|---|
name | 在範本中繫結時使用的管道名。 通常使用 lowerCamelCase 拼寫方式,因為名字中不允許包含減號(-)。 The pipe name to use in template bindings. Typically uses lowerCamelCase because the name cannot contain hyphens. |
pure? | 為 When true, the pipe is pure, meaning that the |
參見
說明
管道類別必須實現 PipeTransform
介面。例如,如果其名稱為 “myPipe”,則使用範本繫結表示式,例如:
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 }}
此表示式的結果會傳給管道的 transform()
方法。
The result of the expression is passed to the pipe's transform()
method.
管道必須屬於某個 NgModule,才能用於範本。要使其成為 NgModule 的成員,請把它加入 NgModule
元資料的 declarations
中。
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.