I use Ionic2 to build an app,which based on Angular2 and Cordova. when I use function setInterval to get a parameter called clickCount,it occurt an undefine error.
export class ItemDetailsPage {
static get parameters() {
return [[NavController], [NavParams]];
}
constructor(nav, navParams) {
this.nav = nav;
this.clickCount = 0;
this.selectedItem = navParams.get('item');
}
startTapped(event) {
var cp= this.clickCount; //here can get the clickCount
this.stop = setInterval(function() {
console.log(this.clickCount); //occur a undefined error
}, 1000);
}
}