How to create angular library using Angular 12 -part 2
In this section, we will see how to create and use the custom pipe by using angular library then use it in the angular application.
The command ng generate pipe <custom-pipe-name> --project=<project-name>
is used to generate pipe.
ng generate pipe ellipsis --project=my-lib
Next step to register the pipe in my-lib.module.ts.
Next step to update the public-api.ts
Now we will add logic to ellipsis pipe to shortened the content with specified length. The transform
method will take two parameters, first parameter is used to pass the value that is being formatted and the second parameter is list of parameters/ arguments passed into our pipe.
After updating the core logic of the pipe. Build the library by using the below command.
ng build --project=my-lib
After successful build, use the pipe in angular application.
To serve the angular application by using following command.
ng serve --project=my-app
In next section will see how to create and use the directive by using angular library then use it in the angular application.