Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create component as a library in Angular Nrwl Nx

Tags:

I'm very new in Angular Nx. I have to create reusable Angular component and store it as a Library according to Nx workspace structure. I can't find appropriate command. I tried create library using:

 ng generate lib mylib

It creates library as expected, but I want to store there component which can be used later in my apps.

like image 640
pumbosha Avatar asked Dec 21 '18 08:12

pumbosha


1 Answers

These are two separate actions - you have to generate a lib in order to create the lib in the workspace (and optionally have a module and import it into another module).

After you do this you can create a component inside this lib.

ng generate component mycomponent --project=mylib --module=mylib.module.ts --export

Note that we are exporting it to use it elsewhere.

like image 77
electrichead Avatar answered Sep 27 '22 21:09

electrichead