Angular

Angular CLI Basics - ng generate pipe

PRO

In this video, we cover how to generate pipes using the Angular CLI. To generate a pipe, you need to run the following command:

ng generate pipe pipe-name

You can add a number of flags after the pipe name, depending on what you need. The flags we covered in this section are:

  • --export
  • --module
  • --flat

In addition to the --module flag, which adds a pipe to a module, you can add a pipe to a module by putting the pipe in the folder of a module, closest to where the module is located. So, if you have a SharedModule in a shared folder, you can add a pipe to that module with the following command:

ng g p shared/pipe-name

For more information on generating pipes, and for a list of all the flags available when generating pipes, you can check out the docs.

If you'd like to know more about pipes and their roles in Angular apps, read this guide from the Angular documentation.