ng-comp-lib v1.1.0
NgCompLib
This project was generated with Angular CLI version 7.1.4.
Development server
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Code scaffolding
Run ng generate component component-name
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module
.
Build
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
Running unit tests
Run ng test
to execute the unit tests via Karma.
Running end-to-end tests
Run ng e2e
to execute the end-to-end tests via Protractor.
Further help
To get more help on the Angular CLI use ng help
or go check out the Angular CLI README.
Steps to create local package :
Steps to create new npm library :
Install CLI :
npm install @angular/cli -g
Create new component library project folder.
ng new my-component-library
- Create a feature module
ng g m Samp
- create the component
ng g c Simple
Simple.component.css Simple.component.html Simple.component.spec.ts Simple.component.ts
Simple.component.html
3.Export our component from our module
import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { SimpComponent } from '../simp/simp.component';
@NgModule({ declarations: SimpComponent, imports: CommonModule , exports: SimpComponent }) export class SampModule { }
- Run npm install ng-packagr --save-dev
- we’ll need to add two files to our project,
ng-package.json and public_api.ts.
6.ng-package.json:
{ "$schema": "./node_modules/ng-packagr/ng-package.schema.json", "lib": { "entryFile": "public_api.ts" } }
7.public_api.ts