【发布时间】:2014-10-02 18:45:07
【问题描述】:
我正面临 state.go 无法按预期工作的问题
以下是各种状态的定义方式
(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));
点击事件使用 state.go 改变视图
scope.goToListbuild = function () {
timeout(function () {
location.path('/' + sessionSvc.get('clientKey') + '/' + sessionSvc.get('orgKey') + '/lists/build');
state.go('recipe');
}, 10);
};
现在,当会话值发生变化时,用户应该被重定向到不同的路径。当前发生的情况是,即使会话值更改了 state.go 也会将其转换为旧 URL。
我尝试了 state.go 和 state.reload 的不同选项,但它不起作用
因此,如果这是主页“/PQR/PQR-sec1/lists”的更改 URL,我单击链接时它实际上会返回到“/ABC/ABC-sec1/lists/build#recipe”而不是“ /PQR/PQR-sec1/lists/build#recipe"
【问题讨论】:
标签: angularjs angular-ui-router