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 use the results of the resolve to redirectTo a new state? #16

Closed
jrynlds opened this issue Dec 13, 2016 · 1 comment
Closed

How to use the results of the resolve to redirectTo a new state? #16

jrynlds opened this issue Dec 13, 2016 · 1 comment

Comments

@jrynlds
Copy link

jrynlds commented Dec 13, 2016

My default state route has a resolve that gets the name of the users default report (view). How can I use the result of that resolve to redirectTo: ?

I see this from the API:

// a fn returning a promise for a redirect
.state('G', {
  redirectTo: (trans) => {
    let svc = trans.injector().get('SomeAsyncService')
    let promise = svc.getAsyncRedirectTo(trans.params.foo);
    return promise;
  }
})

but in this react version... I don't think getAsyncRedirectTo is available... or if it is, I'm not finding it.

and now that I recheck let svc = trans.injector().get('MyService') does not return either. Thows error:
Error: Resolvable async .get() not complete:"MyService"

How should I be doing this?

@jrynlds
Copy link
Author

jrynlds commented Dec 13, 2016

With some help from a friend... we figured this out. Comments are welcome:

redirectTo: (trans) => {
        return trans.injector().getAsync('defaultReportName');
    }

In this example, 'defaultReportName' is the token name for the resolve that get the default report name.

Thanks for such a great tool. Love it.

@jrynlds jrynlds closed this as completed Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant