Creating a library with the Angular CLI
Before we can start working with Angular libraries using the Angular CLI, we need to create an Angular CLI workspace. The Angular CLI workspace will contain our Angular library and an Angular application for testing the library.
Use the following command to generate a new Angular CLI workspace:
ng new my-components --defaults
The preceding command will create a new Angular CLI workspace that contains an Angular application named my-components
. Navigate to the my-components
folder and execute the following command to generate a new Angular library:
ng generate library ui-controls
The preceding command will create a ui-controls
library inside the projects
folder of the workspace. It will contain various files similar to those when creating an Angular application, including the following:
src\lib
: This contains the source code of the library, such as modules, components, and services.src\public-api.ts
: This exports artifacts...