2015-10-12 54 views
0

我已经看到这个thread,但它使用ui-router,我只使用AngularJS的$routeProvider。在线程的代码是:X秒后重定向AngularJS

.controller('SeeYouSoonCtrl', ['$scope', '$state', '$timeout', 
           function($scope, $state, $timeout) { 

    $timeout(function() { 
     $state.go('AnotherState'); 
     }, 3000); 

    }]) 

我怎么能因为我没有使用ui-routerrouteProvider使用它呢?先谢谢你。

回答

3

您需要使用$location服务

$location.path('/anotherURL'); 
+0

就像一个魅力。谢谢 – FewFlyBy

+0

:)很高兴帮助你cheerz :) –

0

通过$location方法:

代码:

.controller('HomeController', ['$scope', '$state', '$location', 
            function($scope, $state, $location) {  
     $location.path('/appurl'); 

     }])