feat(modal): pass modal data to onClose instance

Closes #668
This commit is contained in:
Adam Bradley
2015-11-30 17:14:39 -06:00
parent 041ec6a06f
commit 022e0b5396
2 changed files with 16 additions and 8 deletions

View File

@ -34,7 +34,14 @@ class E2EApp {
}
openToolbarModal() {
this.modal.open(ToolbarModal);
this.modal.open(ToolbarModal).then(modalRef => {
// modal has finished opening
// modalRef is a reference to the modal instance
modalRef.onClose = (modalData) => {
// somehow modalRef.close(modalData) was called w/ modalData
console.log('modalRef.onClose', modalData)
}
});
}
openModalChildNav() {
@ -57,17 +64,13 @@ class E2EApp {
template: `
<h3>Pass Params</h3>
<p>User Id: {{userId}}</p>
<p><button (click)="closeModal()">Close Modal</button></p>
<p><button (click)="close()">Close Modal</button></p>
`
})
class ModalPassParams {
constructor(private modal: Modal, params: NavParams) {
this.userId = params.get('userId');
}
closeModal() {
this.modal.get().close();
}
}
@ -93,8 +96,12 @@ class ToolbarModal {
constructor(private modal: Modal) {}
closeModal() {
this.modal.get().close();
this.close({
adel: 'hello',
lionel: 'hello'
});
}
}

View File

@ -29,9 +29,10 @@ export class OverlayController {
}
}
viewCtrl.instance.close = (closeOpts={}) => {
viewCtrl.instance.close = (data, closeOpts={}) => {
extend(opts, closeOpts);
opts.animation = opts.leaveAnimation;
viewCtrl.instance.onClose && viewCtrl.instance.onClose(data);
this.nav.pop(opts);
document.removeEventListener('keyup', escape, true);
};