A Simple custom maxlength directive in Angular 8 and Ionic 4 for input fields that allows user to enter maximum number of characters as given.
npm install custom-maxlength
npm install custom-maxlength --save
`
Usage
- Import CustomMaxlengthModule in your app.module.ts.
`
import {CustomMaxlengthModule} from 'custom-maxlength';
`
`
@NgModule({
imports: [
...,
CustomMaxlengthModule,
...
]
})
`
Example-1 (ion-input type="text")
`
value=""
formControlName="title"
custom-maxlength
[charMaxLength]="50"
required
[(ngModel)]="title">
`
Example-2 (ion-textarea)
`
custom-maxlength
[charMaxLength]="500"
required
[(ngModel)]="description">
``