$ state.go将从指定的状态转到另一个状态

时间:2015-04-04 12:43:33

标签: javascript angularjs angular-ui-router

我已在我的应用中定义了此路由规则:

.config(function($stateProvider, $urlRouterProvider) {
  // Ionic uses AngularUI Router which uses the concept of states
  // Learn more here: https://github.com/angular-ui/ui-router
  // Set up the various states which the app can be in.
  // Each state's controller can be found in controllers.js
  $stateProvider
    .state('signin', {
      url: '/sign-in',
      templateUrl: 'templates/sign-in.html',
      controller: 'SignInCtrl'
    })
    .state('tab', {
      url: "/tab",
      abstract: true,
      templateUrl: "templates/tabs.html"
    })
    .state('tab.map', {
      url: '/map',
      views: {
        'tab-map': {
          templateUrl: 'templates/tab-map.html',
          controller: 'MapCtrl'
        }
      }
    })
    .state('tab.mic', {
      url: '/mic',
      views: {
        'tab-mic': {
          templateUrl: 'templates/tab-mic.html',
          controller: 'MicCtrl'
        }
      }
    })
    .state('tab.camera', {
      url: '/camera',
      views: {
        'tab-camera': {
          templateUrl: 'templates/tab-camera.html',
          controller: 'CameraCtrl'
        }
      }
    })
    .state('tab.video', {
      url: '/video',
      views: {
        'tab-video': {
          templateUrl: 'templates/tab-video.html',
          controller: 'VideoCtrl'
        }
      }
    })
    .state('tab.message', {
      url: '/message',
      views: {
        'tab-message': {
          templateUrl: 'templates/tab-message.html',
          controller: 'MessageCtrl'
        }
      }
    })
    .state('tab.account', {
      url: '/account',
      views: {
        'tab-account': {
          templateUrl: 'templates/tab-account.html',
          controller: 'AccountCtrl'
        }
      }
    });

  // if none of the above states are matched, use this as the fallback
  $urlRouterProvider.otherwise('/sign-in');

在我的一个控制器中,我尝试这样做:

    $state.go('signin');

但这显然会重定向到&tab ;.video'。知道为什么会发生这种情况吗?

0 个答案:

没有答案