What is the right way to do this in AngularJS? I didn\'t find any simple answer to this.
I\'d like to :
Basically, Their are two way $location
and $timeout
. This will solve your issue:
- By
$timeout
method :
code :
.controller('HomeController', ['$scope', '$state', '$timeout',
function($scope, $state, $timeout) {
$timeout(function() {
$state.go('anotherstate');
}, 4000);
}])
- By
$location
method :
code:
.controller('HomeController', ['$scope', '$state', '$location',
function($scope, $state, $location) {
$location.path('/appurl');
}])