How to auto redirect after X seconds in AngularJS?

前端 未结 5 783
自闭症患者
自闭症患者 2021-01-17 22:24

What is the right way to do this in AngularJS? I didn\'t find any simple answer to this.

I\'d like to :

  1. Load a page
  2. Wait for X seconds
5条回答
  •  礼貌的吻别
    2021-01-17 23:12

    This works (thanks PSL):

    .controller('SeeYouSoonCtrl', ['$scope', '$state', '$timeout',
                                    function($scope, $state, $timeout) {
    
        $timeout(function() {
          $state.go('AnotherState');
          }, 3000);
    
        }])
    

提交回复
热议问题