Hi, I am just starting with Ionic (and app development generally), and I got stuck on the following issue:
- On one page, user inputs data (name of a goal):
.html file:
<ion-item>
<ion-label floating>Goal name</ion-label>
<ion-input type="text" max=10 [(ngModel)]="NewGoal.goalname" name='goalname'></ion-input>
</ion-item>
.ts file:
export class NewGoalPage {
constructor(public navCtrl: NavController, public navParams: NavParams, public storage: Storage) {
}
NewGoal = { goalname:' '};
setGoal () {
this.storage.set("myGoal", this.NewGoal.goalname);
}
}
- And then on a different page I want to show the stored goal name when user clicks a button “Get goal”:
.ts file:
getGoal () {
this.storage.get('myGoal').then((goal)=> {
console.log(goal);
});
I call this method on the button click, and it definitely works because I can see the user-input string in the console when testing with the “ionic lab” (ie. the storage is set-up correctly). I just have no idea on how to display the same value on the page - what do I need to include in the HTML file?
I would appreciate any tips or links.
Thank you