Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 在angular js中使用$location.path时,Url路径未更改_Angularjs_Ionic - Fatal编程技术网

Angularjs 在angular js中使用$location.path时,Url路径未更改

Angularjs 在angular js中使用$location.path时,Url路径未更改,angularjs,ionic,Angularjs,Ionic,检查if条件时,在angular js中使用$location.path时,Url路径不会更改。 我将在下面发布我的代码片段以供参考 App.js: .state('home.selectCart',{ url:'/cart_selection', views: { content: { template: '', controller: 'SelectCa

检查if条件时,在angular js中使用
$location.path
时,Url路径不会更改。 我将在下面发布我的代码片段以供参考

App.js

.state('home.selectCart',{
          url:'/cart_selection',
          views: {
              content: {
                  template: '',
                  controller: 'SelectCartCtrl'
              }
          },
          authenticate: true
        })
.controller('SelectCartCtrl', [ '$scope' ,'ProductFactory', '$location', function($scope,ProductFactory, $location){

      $scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
        var cartType = ProductFactory.getCartType();
        if(cartType == 'b2b') {
           $location.path('/home/b2b/cart');
        }
        if(cartType == 'b2c'){
          $location.path('/home/cart');
        }
      });
}])
Controller.js

.state('home.selectCart',{
          url:'/cart_selection',
          views: {
              content: {
                  template: '',
                  controller: 'SelectCartCtrl'
              }
          },
          authenticate: true
        })
.controller('SelectCartCtrl', [ '$scope' ,'ProductFactory', '$location', function($scope,ProductFactory, $location){

      $scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
        var cartType = ProductFactory.getCartType();
        if(cartType == 'b2b') {
           $location.path('/home/b2b/cart');
        }
        if(cartType == 'b2c'){
          $location.path('/home/cart');
        }
      });
}])

在我的html文件中,我使用
href=“#/home/cart\u selection”
进行选项卡选择:

否。。我是安格拉斯的新手。您能帮我一下吗?我收到了这个错误:错误:[$rootScope:inprog]$digest已经在进行中。您在控制台中是否收到任何错误?请尝试使用location.hash而不是location.path