export class HomePage {
public multipleOptions: Array < {
option: any
} > ;
public currentValue: any;
public arrayIndex: any;
constructor(public navCtrl: NavController) {
this.multipleOptions = [{
option: '1'
},
{
option: '2'
},
{
option: '3'
},
{
option: '4'
},
{
option: '5'
}
]
}
runit() {
if(this.arrayIndex==null)
this.arrayIndex = 0;
else
this.arrayIndex++;
if(this.arrayIndex>=this.multipleOptions.length)
this.arrayIndex = 0; //this is just to restart if you don't want this just block the increment
this.currentValue = this.multipleOptions[this.arrayIndex].option;
}
}
Html:
<h2>{{currentValue}}</h2>
<button ion-button large (click)='runit()'>Start</button>