A component for displaying forms errors in Ionic Apps
npm install form-errorsnpm install form-errors.
typescript
import { FormErrorsModule } from 'form-errors';
imports: [
IonicModule.forRoot(MyApp),
FormErrorsModule
]
`
Using form-errors in an Ionic 3 app
Import module into the module of the page you want to use in session imports
`typescript
import { FormErrorsModule } from 'form-errors';
imports: [
IonicPageModule.forChild(LoginPage),
FormErrorsModule
]
`
## How to use
In your HTML, declare your formGroup and formControlName inside the form-item;
Out of your ion-item use the tag with the desired parameters
Ex:
`html
`
In your .ts, declare and initialize your formGroup by validating the fields according to rules applicable to each field;
Ex:
`typescript
this.formLogin = this.formBuilder.group({
email: ['', Validators.required, Validators.email],
password: ['', Validators.required, Validators.pattern("^(?=.[A-Za-z])(?=.\d)[A-Za-z\d]{8,}$")], //Letters And numbers min 8 characters
})
``