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
Forcing router refresh #23
Comments
Did you find a solution for this? I have run into the same problem. |
This seems to do the trick: .segment('index', {
templateUrl: 'assets/templates/index.html',
controller: IndexCtrl,
dependencies: ['index'],
resolve: {
data: function(Article, $q, $location) {
var deferred = $q.defer();
Article.getAll().get({},
function(successData) {
deferred.resolve(successData);
}, function(errorData) {
deferred.reject();
});
return deferred.promise;
}
},
untilResolved: {
templateUrl: 'assets/templates/loading.html'
},
resolveFailed: {
// ToDo: Error template and controller should be here.
templateUrl: 'assets/templates/login.html',
controller: LoginCtrl
}}) |
What does your LoginCtrl do on a successful login to reload the index segment? |
$location.path('/index'); |
We've still got a bug with this approach - we'll post a solution here (and on SO) once we've fixed it. |
FYI we ended up with a hack, forcefully refreshing the entire page in order to refresh the router. Had a deadline and no time to play around and get to the bottom of things :( |
Did you have a look to .segment('index', {
...
watcher: function(injectables) {
...
return result; // when result is changed, the segments gets reloaded
}
}) |
Already on SO: http://stackoverflow.com/questions/19812911/is-it-possible-to-refresh-route-segment-provider-in-angularjs
Basically, I'm using:
resolve: ['isUserLoggedIn'],
resolveFailed: {
templateUrl: 'assets/templates/login.html',
controller: LoginCtrl
}
to redirect to login page if user is not yet logged in.
The login controller redirects back to /#/index if user logged in successfully, but it seems that templateUrl and controller have already been decided and they don't get refreshed, isUserLoggedIn does not get called for the second time. Is this intended behaviour? Is there a way to forcefully refresh routing after initial setup?
The text was updated successfully, but these errors were encountered: