i have .js file as below
routerApp.config(function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise(function ($injector, $location) {
var $state = $injector.get('$state');
var path = $location.protocol();
if (path == 'http') {
$state.go('external');
}
else {
return '/home';
}
});
$stateProvider
// HOME STATES AND NESTED VIEWS ========================================
.state('home', {
url: '/home',
templateUrl: 'routing.html'
})
.state('external', {
onEnter: function ($window) {
$window.open('http://www.google.com', '_self');
}
});
});
above code works fine when path != 'http', it will redirect to routing.html. But when path == 'http', it should call external state and redirect to external url. Here path == 'http' condition is not working. How to call external url here? and in state I am calling external onEnter. Can I do it without OnEnter?