Segment

Segment is another new introduction to Ionic. This component is used to control radio selections. We will be scaffolding another application to work with this example. From inside the chapter3 folder, run the following:

ionic start -a "Example 7" -i app.example.seven example7 blank --v2 

cd into example7 folder and run ionic serve --lab, and you should see the home page of the blank template.

Now, to work with segment, we add the following code snippet inside the ion-content directive in the src/pages/home/home.html file:

    <ion-segment [(ngModel)]="food" color="primary">         <ion-segment-button value="pizza">             Pizza         </ion-segment-button>         <ion-segment-button value="burger">             Burger         </ion-segment-button>     </ion-segment>  <div [ngSwitch]="food"> ...

Get Learning Ionic - Second 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.