How it works...

The homepage template (home.html) is very typical with ion-list and ion-item, which contain your input elements. However, there are two important things to take note of. Firstly, there is an attribute, called myIonicInput, in the ion-input component. Observe the following code:

<ion-item > 
  <ion-input type="text" placeholder="Username"    [(ngModel)]="username" [myIonicInput]="myStyles"></ion-input> 
</ion-item> 

Secondly, the myStyles object is now used to toggle the visibility of the <p> element, as shown:

<p *ngIf="myStyles.showUsername" class="hint"> 
  You are typing username 
</p> 

This myStyles object is actually a private variable in your HomePage class in the home.ts file, as follows:

export class HomePage { private myStyles: ...

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.