Reputation: 77
I'm facing this issue with state.go not working as expected
Below is how various states are defined
(function (app) {
'use strict';
app.ng.requires.push('ui.bootstrap');
//app.ng.requires.push('ngGrid');
app.ng.requires.push('ui.router');
app.ng.requires.push('ngTouch');
app.ng.requires.push('ngAnimate');
app.ng.run(
['$rootScope', '$state', '$stateParams',
function ($rootScope, $state, $stateParams) {
debugger;
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
}
]
);
app.ng.config(
['$stateProvider',
function ($stateProvider) {
debugger;
var modulePath = 'modules/listBuild';
var ctrlRoot = app.root + modulePath + '/Views/';
$stateProvider
.state('recipe',
{
url: '#recipe',
templateUrl: ctrlRoot + 'selectRecipe.html'
})
.state('selectLocation',
{
url: '#selectLocation',
templateUrl: ctrlRoot + 'selectLocation.html'
})
}]);
}(window.app));
and click event to change the view using state.go
scope.goToListbuild = function () {
timeout(function () {
location.path('/' + sessionSvc.get('clientKey') + '/' + sessionSvc.get('orgKey') + '/lists/build');
state.go('recipe');
}, 10);
};
now when ever the session value changes the user should be redirected to different paths. what currently happening is even if the session value changes the state.go takes it to older URL.
I tried differenet options of state.go and state.reload but it doesn't work
So if this is the changed URL of Home page "/PQR/PQR-sec1/lists" where i click the link it actually goes back to "/ABC/ABC-sec1/lists/build#recipe" instead of "/PQR/PQR-sec1/lists/build#recipe"
Upvotes: 0
Views: 1442
Reputation: 1624
I think you a bad url defined for your state define for example :
$stateProvider
.state('recipe',
{
url: '/recipe', //url which looks like myDomain.com/#/recipe
templateUrl: ctrlRoot + 'selectRecipe.html'
})
.state('selectLocation',
{
url: '/selectLocation',
templateUrl: ctrlRoot + 'selectLocation.html'
});
But i suggest that you use "ui-sref" in your html because I think you change it onClick so juste use something like this
<a ui-sref="recipe"> </a>
If it doesn't work try to comment your line location.path(...)
Upvotes: 2