I am using the this great angular2-modal but can't figure out how to return a result value from my custom modal.
I instantiate it like this:
let dialog: Promise<ModalDialogInstance>;
let bindings = Injector.resolve([
provide(ICustomModal, { useValue: this.gewaehltesBild })
]);
var self = this;
dialog = this.modal.open(
<any>ImagecropperComponent,
bindings,
new ModalConfig("md", true, 27));
dialog.then((resultPromise) => {
return resultPromise.result.then((result) => {
this.lastModalResult = result;
this.mitarbeiter.avatarImg = this.gewaehltesBild;
$(self.elementRef.nativeElement).find('#bildSelector').val("");
}, () => this.lastModalResult = 'Rejected!');
});
I have tried to send my returnvalue with
this.dialog.close(this.croppedImage);
but result is always null. Is there a convention in angular2 how to return values from components, that is used by angular2-modal?
Thank you!
Works fine for me, I too am using custom dialog and here is how i catch the result
var dialog = this._modal.open(VideoPlayerComponent,
resolvedBindings,
new ModalConfig('lg', true, 27));
dialog
.then((d) => d.result)
.then((r) => { console.log(r); }, (error) => { console.log(r); });
When i call close
on the instance
this._dialog.close("Hello");
It does print Hello
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With