Hi all,
I’am facing a noob issue
This is my situation :
I have a simple list (with items) with an “add” button. Clicking on “add” button open “new item” window, then when i save, i close the window and i coming back to the list. Nothing complicated
My problem is that when i save my new item, i’m not able to refresh the list…I think it’s just a syntax problem…I’m not yet an expert with Angular / TS
So, this is a sample code of my list
...
// Refresh list
refreshMyList(){
this.Db.getList().then((data)=> this.myList = data); //Db is my database provider
}
// Open new item modal
addItem(){
// HERE IS MY PROBLEM
this.navCtrl.push(NewItem,{callback: function(){
this.refreshMyList(); // doesn't work of course "this" is out of scope, i've tried a lot of thing but still doesn't work
}});
}
And, in my New item page sample code
...
constructor(public navCtrl: NavController, private viewCtrl: ViewController, private args: NavParams) {
this.callback = args.get("callback"); // my callback parameter
}
save(){
// here i saving my new item in database ...
...
// call my list callback
this.callback();
this.viewCtrl.dismiss();
}
...
Thanks for your help