April 2017
Beginner to intermediate
378 pages
7h 57m
English
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"> ...Read now
Unlock full access