I have 2 pages, Home and Settings.
Home is supposed to get category from the localstorage. But its failing to do so.
getDefaults(){
if(localStorage.getItem('category') != null){
this.category = localStorage.getItem('category');
} else {
this.category = 'sports';
}
}
changeCategory(){
this.getPosts(this.category, this.limit);
}
I have settings page like this
getDefaults(){
if(localStorage.getItem('category') != null){
this.category = localStorage.getItem('category');
} else {
this.category = 'sports';
}
if(localStorage.getItem('limit') != null){
this.limit = localStorage.getItem('limit');
} else {
this.limit = 10;
}
}
setDefaults(){
localStorage.setItem('category', this.category);
localStorage.setItem('limit', this.limit);
this.navCtrl.push(HomePage);
}
All I want to do is from the settings page when I change category not to use navCtrl.push and create a new page that would go back to settings but move it to HomePage.