0.0.1 • Published 2 years ago

first-npm-packagee v0.0.1

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

FirstNpmPackage

This library was generated with Angular CLI version 15.2.0.

Code scaffolding

Run ng generate component component-name --project first-npm-package to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module --project first-npm-package.

Note: Don't forget to add --project first-npm-package or else it will be added to the default project in your angular.json file.

Build

Run ng build first-npm-package to build the project. The build artifacts will be stored in the dist/ directory.

Publishing

After building your library with ng build first-npm-package, go to the dist folder cd dist/first-npm-package and run npm publish.

Running unit tests

Run ng test first-npm-package to execute the unit tests via Karma.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI Overview and Command Reference page.

Steps of Creating Library with Angular

The current library displays a simple form to handle user input data. After installing Angular CLI and creating your angular Project , follow these steps to create your angular library correctly.

Step 1: Create Library

This command will create a library project into the current project. Angular library have module, services, components, etc.

ng generate library library_name

Step 2: Make a functionality into your library

We can add more components, services, directives, pipes and modules as needed.

Step 3: Build and consume Angular library

This command will generate library dist folder. After build successfully we can get 2 paths.

ng build library_name

Step 4: Implement library into current project

  1. In app.module.ts import library module .
  2. Import selector tag of library in app.component.html file to load library.
  3. To find selector tag of library open projects/lib/src/lib/my-lib.component.ts file, where you can get selector inside @component decorator.

Step 5: Implement library into another project

  1. Copy the 'dist' folder to the other project where you want to use the library .

  2. In the other project run this command

npm install path-to-your-library/dist/library_name 
  1. In app.module.ts import library module .
  2. Import the selector tag of library in app.component.html .
0.0.1

2 years ago