Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass asynchronous data onto the modal controller, like ui-bootstrap modal resolve ?? #132

Open
ghost opened this issue Aug 26, 2015 · 1 comment
Labels

Comments

@ghost
Copy link

ghost commented Aug 26, 2015

Although according to the docs and examples, you can pass data onto the modal controller using the third parameter data in dialogs.create('address/to/modal/template.html', 'ModalController', data, opts), this is only good for ready data only, and not for asynchronous data.

UI-Bootstrap native modal, has the resolve property to handle asynchronous data, and since this library is build on top of that, how would I got on utilizing this functionality of UI-Bootstrap Modal?

I already tried passing a resolve property inside the fourth parameter opts

var opts = {'resolve': {'asyncData': fnWhichReturnsPromise()}};
dialogs.create('address/to/modal/template.html', 'ModalController', data, opts);

but although the function did get called upon opening the modal, I dont know how to get the retrieved data onto my ModalController. I already tried injecting the key name of my async data but with no luck

/* @ngInject */
function ModalController ($modalInstance, data, asyncData) {} // this produce an error stating unknown provider asyncData
@wjaspers
Copy link

Resolve only resolves 'data' so the default controllers behave in a consistent and predictable manner.
See https://github.com/m-e-conroy/angular-dialog-service/blob/master/src/dialogs-services.js#L260

You can fire the modal when the data is available ...

var asyncData = fnWhichReturnsPromise().then(function (result) {
  data.asyncData = result;
  return dialogs.create('/address/to/modal/template.html', 'ModalController', data).result;
}, function () { 
// something bad happened 
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants