ionic form value code example

Example 1: ionic form example

// in component.ts
this.myForm = formBuilder.group({
    firstName: ['value'],
    lastName: ['value', *validation function goes here*],
    age: ['value', *validation function goes here*, *asynchronous validation function goes here*]
});

...

// in component.html
<form [formGroup]="myForm">
    <ion-input formControlName="firstName" type="text"></ion-input>
    <ion-input formControlName="lastName" type="text"></ion-input>
    <ion-input formControlName="age" type="number"></ion-input>
</form>

Example 2: ionic disable input field

<ion-item class="order__status-comments">
  <ion-label floating>Observação</ion-label>
  <ion-input formControlName="comments" [readonly]="status_loading" type="text"></ion-input>
</ion-item>

Tags:

Html Example