First you need to install the npm module, after update the package.json that declare it as dependency:
npm install
Once installed you need to import the main module into your application module by importing NgxTimeMaskModule.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgxTimeMaskModule } from 'ngx-time-mask';
@NgModule({
imports: [
BrowserModule,
NgxTimeMaskModule
],
bootstrap: [AppComponent]
})
export class AppModule { }
This is how you do it with the directive:
<input class="time-count" ngxTimeMask [maxHour]="23" [minHour]="00" [(ngModel)]="data" (change)="onTimeChange($event)">
Set a max and min hour to set, by default is set from 01 to 12. And in your component define data.
ngx-time-mask
is packaged with ng-packagr and then imported into an Angular CLI app.
To check the demo, click:
***Copyrigths MIT © Avinash Maurya