Download and install Node.js
β¬
Open Terminal
or Command Prompt
and check node version using command node -v
β¬
Now, type in npmβ―installβ―-gβ―@angular/cli
to install CLI
β¬
Check CLI version using ng --version
β¬
Create Angular workspace using ng new <app_name>
β¬
app_name consider as libraryApp
β¬
To create library init, use ng g library <library_name>
β¬
library_name
consider as myLib
β¬
Inside the projects
folder, go to mylib component inside myLib
library.
β¬
Design reusable component in it.
β¬
Now, build that library using ng build <library_name>
β¬
Library gets generated in dist
folder
Using this library in same application.
Import myLib
module in app.module.ts
of application
β¬
Access components or services of myLib
library inside application and use wherever required in application
β¬
Now, do ng serve
to check the application
Using in external application
ng new externalApp
- Create new external application
β¬
In the ng build myLib
log, dist
folder locations are shown
β¬
take lib
path and do npm i <path>
inside new external application
β¬
Import myLib
module in app.module.ts
of application
β¬
Access components or services of myLib
library inside application and use wherever required in application
β¬
Now, do ng serve
to check the application
Top comments (0)