How to auto redirect after X seconds in AngularJS?
This works (thanks PSL):
.controller('SeeYouSoonCtrl', ['$scope', '$state', '$timeout',
function($scope, $state, $timeout) {
$timeout(function() {
$state.go('AnotherState');
}, 3000);
}])
It does work also using $location
instead of $state
!
JS
app.controller('SeeYouSoonCtrl', function($scope, $location, $timeout) {
$timeout(function() {
$location.path('/nextsite');
}, 3000);
});