Hi All, I’m siva and I’m new to ionic 2 and angular 2 .This issue is related to ion-segment component.
in my program I want to select particular segment item programatically from class but i couldn’t achieve this even after using ngmodel and kindly fine my below code and html template.
map.ts
import {Page, NavController} from ‘ionic-angular’;
import {Renderer,ElementRef} from ‘@angular/core’;
import{NgControl} from ‘@angular/common’
@Page({
templateUrl: ‘build/pages/map/map.html’
})
export class MapPage {
/water new order variable=/
can_count:number;
constructor(
private nav: NavController) {
this.can_count=2;
/this.initializeItems();/
}
}
and HTML template is
map.html
"
<ion-list no-lines>
<!-- number of can -->
<ion-card>
<ion-card-header>
Number of water can : {{can_count}}
</ion-card-header>
<ion-card-content>
<ion-segment [(ngModel)]="can_count" inverse>
<ion-segment-button value="1" >
1
</ion-segment-button>
<ion-segment-button value="2">
2
</ion-segment-button>
<ion-segment-button value="3">
3
</ion-segment-button>
<ion-segment-button value="4">
4
</ion-segment-button>
<ion-segment-button value="5">
5
</ion-segment-button>
</ion-segment>
</ion-card>
</ion-list>
</ion-content>
"
kindly anybody help me on this to select segment item through program.