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

get $state info of toState in resolve #1018

Closed
gruppjo opened this issue Apr 10, 2014 · 10 comments
Closed

get $state info of toState in resolve #1018

gruppjo opened this issue Apr 10, 2014 · 10 comments
Milestone

Comments

@gruppjo
Copy link

gruppjo commented Apr 10, 2014

Hi,

I would like to access the state the app is trying to navigate to in a resolve. Apparently it's possible to get the state you're navigating away from by injecting $state, but not the state you're navigating to.
I don't know whether this is a bug or a feature request. But it would be great to be able to do so. I've been able to work around it (more details in link) but I think they're all messy.

I prepared a stackoverflow question for this:

http://stackoverflow.com/questions/22985988/angular-ui-router-get-state-name-in-resolve

@MathiasTim
Copy link

👍 for some information here, having the same issue...

thanks!

@mmoulton
Copy link

+1 for this. Just tried doing this today and am unable to.

Would be happy to submit a PR for this if it's trivial. Some direction on where to look would be appreciated though as I'm not yet familiar with the code base.

@gruppjo gruppjo changed the title get state name in resolve get $state info of toState in resolve Sep 9, 2014
@KobiSh
Copy link

KobiSh commented Jan 14, 2015

+1

@gruppjo
Copy link
Author

gruppjo commented Jan 14, 2015

TaylorMac proposed a good and clean workaround using a decorator - http://stackoverflow.com/a/27255909/1574201

@KobiSh
Copy link

KobiSh commented Jan 14, 2015

this way also works..

angular.module('regions').factory('RegionsModalServices',['$modal', '$state',
function($modal, $state) {
return ({
openCreateEditRegions: function (size, regionId, tableParamsList) {
var modalInstance = $modal.open({
templateUrl: $state.get('createRegion').templateUrl,
controller: 'RegionsCreateEditController',
size: size,
backdrop: 'static',
windowClass: 'modal-edit-task',
resolve: {
regionId: function () {
return regionId;
},
tableParamsList: function () {
return tableParamsList;
}
}
});

        }
    });
}

]);

@kayhadrin
Copy link

+1 for this.
It's good to have a good workaround from SO, but it'd be better to have it there by default.

@nateabele
Copy link
Contributor

This is slated for an upcoming release.

@nateabele nateabele added this to the 1.0.0-preview milestone Mar 31, 2015
@jamesbrobb
Copy link

Any idea when the version containing this feature is due for release?

@nateabele
Copy link
Contributor

@jamesbrobb It's Open Source, so nobody really knows. 😄 We did just get the sample app running on it this morning though, so an alpha is probably due out soon.

@nateabele
Copy link
Contributor

Fixed in 1.0-alpha, which is shipping tomorrow.

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

7 participants