dk-number-formatter v2.2.0
Sample Component Library
Sample project to demo how to share angular component module via NPM
Build and Publish
To package and publish component module, we need to install a packager that will transform this module into a library identifiable as an NPM Package. For that we choose “ng-packagr” which Transpiles your libraries to Angular Package Format. It is an NPM Package built as a wrapper over “Roll-Up” which is a module bundler that compiles code into Libraries and Applications.
Install ng-packagr:
npm install ng-packagr --save-dev
Package module as library:
npm run packagr
Navigate to 'dist' directory
cd dist
Package library for deployment to NPM:
npm pack
Login to NPM
npm login
Publish to NPM:
npm publish
How to consume component/s
Installation
npm install dk-number-formatter --save
Importing the Module
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { DkNumberFormatterModule } from 'dk-number-formatter';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
DkNumberFormatterModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Selector
<dk-number-formatter [ngNumber]="'1222130'"></dk-number-formatter>