Using JavaScript, we have the ability to change the location of a webpage.
window.location.href //to change location
For instance: suppose I am currently on
and now I wish to navigate to
We can accomplish this by simply writing
window.location.href ="https://news.google.co.in/"
This will redirect us to the specified page
In your project, you may have defined your routing as follows:
function routeConfig($stateProvider, $urlRouterProvider, $httpProvider) {
$stateProvider
.state('landing.home', {
url: '/home',
templateUrl: "app/components/homeFolder/home.html",
controller: 'homeController',
controllerAs: 'homec'
})
.state('landing.hometwo', {
url: '/home1',
templateUrl: "app/components/OnHand/Templates/OnHandhome.html",
controller: 'OnHandController',
controllerAs: 'Onhand'
})
})
If you are in an AngularJS controller, you can easily navigate using:
$state.go('landing.home');// to navigate to your required location
However, if you are not within an AngularJS Module, you can use window.location to navigate to the desired page
For example, to achieve ---$state.go('landing.home'); you would write:
window.location.href ="https:complete url"
or alternatively
window.location.hash ="#/home1" //the url which is defined for that state