Angularjs $state.go重定向到旧URL而不更改状态

Angularjs $state.go重定向到旧URL而不更改状态,angularjs,angular-ui-router,Angularjs,Angular Ui Router,我正面临与州政府的这一问题。不能按预期工作 下面是各种状态的定义 (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'

我正面临与州政府的这一问题。不能按预期工作

下面是各种状态的定义

(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);
};
现在,当会话值更改时,用户应该重定向到不同的路径。当前发生的情况是,即使会话值更改了状态,go也会将其移到较旧的URL

我尝试了state.go和state.reload的不同选项,但都不起作用


因此,如果这是主页“/PQR/PQR-sec1/lists”的更改URL,我在其中单击链接,它实际上会返回到“/ABC/ABC-sec1/lists/build#recipe”,而不是“/PQR/PQR-sec1/lists/build#recipe”

我认为您为您的州定义了一个错误的URL,例如:

$stateProvider
  .state('recipe',
  {
     url: '/recipe', //url which looks like myDomain.com/#/recipe 
     templateUrl: ctrlRoot + 'selectRecipe.html'
  })
  .state('selectLocation',
  {
     url: '/selectLocation',
     templateUrl: ctrlRoot + 'selectLocation.html'
  });
但我建议您在html中使用“UISREF”,因为我认为您可以在单击时更改它,所以只需使用类似这样的内容

  <a ui-sref="recipe"> </a>


如果它不起作用,请尝试注释您的行
location.path(…)

,我认为我无法使用ui sref,因为它是有条件的,并且在使用state.go()之前必须使用更改的位置。。。我真正想知道的是,如果有什么东西可以重新加载pathi,我用window.location.href更改了location.path,并且成功了,但我真的不认为我会使用这种方法,但它会帮助别人在这方面提出一些建议,这对我有帮助:)谢谢