PUSHED PAGE TEMPLATE
constructor(public navCtrl: NavController, public navParams: NavParams)
{
this.callback = this.navParams.get('callback');
this.data = this.navParams.get('data') || [];
}
sendData(event: any): void
{
this.callback(this.data).then(()=>{ this.navCtrl.pop() });
}
414,
PUSHED PAGE CLASS
나는
Ionic forum에 비슷한 질문을 대답했다. 방금
Events listeners
을 사용하여이 문제를 해결했습니다.
MainPage-
import { NavController, Events } from 'ionic-angular';
import { OtherPage } from '../other/other';
export class MainPage{
constructor(private navCtrl: NavController,
private events: Events) { }
private pushOtherPage(){
this.events.subscribe('custom-user-events', (paramsVar) => {
// Do stuff with "paramsVar"
this.events.unsubscribe('custom-user-events'); // unsubscribe this event
})
this.navCtrl.push(OtherPage); // Push your "OtherPage"
}
}
OtherPage-
export class OtherPage {
// Under some function
this.navCtrl.pop().then(() => {
// Trigger custom event and pass data to be send back
this.events.publish('custom-user-events', myCustomParams);
});
}
감사합니다, 뭐죠 대상 페이지의 코드? – Fray
오, 죄송합니다. 나는 그것으로 답변을 업데이트했습니다. – anonym
고마워요 ^^ 작동합니다 – Fray