How it works...

Since this recipe uses reactive forms, let's first take a look at home.ts, which initializes and sets up our form.

In the HomePage class, we have registerForm:FormGroup property, which is the collection of FormControl. Each FormControl is bound to the native FormControl in our template. In order to create FormGroup, we can do something like the following:

this.myForm = new FormGroup({ first: new FormControl('Nancy', Validators.minLength(2)), last: new FormControl('Drew'),});

In the preceding example, we are creating a FormGroup named myForm. The FormGroup constructor takes an object as input, which is the collection of FormControl. Each key in this object refers to some native FormControl in the template. The value in the ...

Get Ionic Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.