David D. David D. - 1 month ago 10x
AngularJS Question

How to auto redirect after X seconds in AngularJS?

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

  3. Being automatically redirected to another page after these seconds.

Note: I'm using ui-routing (states) to perform redirections



This works (thanks PSL):

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

    $timeout(function() {
      }, 3000);