$ state.go不会更改网址,但会重定向到该特定网页

时间:2015-12-01 12:54:41

标签: angularjs

我无法使用$ state.go更改我的Url但是我收到了我在$ state.go中请求的页面,我也使用了route.js

angular.module("myApp")
    .controller('myController', ['$scope','$state',  function ($scope, $state) {
      $scope.showDetails = function(data){
                if(some true condition){
                  $state.go("create.preemp");
                  }
                else if(some true condition){
                  $state.go("create.prepolicy");
                }
            }
    }])


angular.module("myApp")
    .config(function ($stateProvider, $routeProvider, $urlRouterProvider) {
        $stateProvider
          .state('signin', {
            url: '/',
            templateUrl: 'signin/signin.html',
            controller: 'signinController'
          })
          .state('create.preemp', {
            url: '/create.preemp',
            templateUrl: 'preemp.html',
            controller: 'preempController'
           })
          .state('create.prepolicy', {
            url: '/create.prepolicy',
            templateUrl: 'prepolicy.html',
            controller: 'prepolicyController'
          })
        $urlRouterProvider.otherwise('/');   
    })  

...

0 个答案:

没有答案