wobsoriano
wobsoriano

Reputation: 13462

Redirect after X seconds AngularJS

I already saw this thread but it uses ui-router and I'm only using the $routeProvider of AngularJS. The code in the thread is:

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

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

    }])

How can I use it with my routeProvider since I am not using ui-router? Thank you in advance.

Upvotes: 0

Views: 1217

Answers (2)

Kumar Rakesh
Kumar Rakesh

Reputation: 2708

By $location method :

code:

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

        }])

Upvotes: 0

Kalhan.Toress
Kalhan.Toress

Reputation: 21901

You need to use $location service

$location.path('/anotherURL');

Upvotes: 3

Related Questions