Reputation: 182
I am trying to open a state in newtab but not able to achieven it. I am doing so using $state,go function.
I tried the below code too which was succesful and opend my url in newtab but browser is blocking the opening of new url in new tab.
openurlnw = $state.href('home.forward',{"url":$scope.platforms[0].url,"name":$scope.platforms[0].name,"dish_name":$scope.userSearchedDish});
window.open(openurlnw,'_blank');
I want to open my state in new tab without letting the browser to block it.
Upvotes: 2
Views: 5349
Reputation: 295
You would have to use absolute
option in constructing url, then just use $window.open
Replace:
openurlnw = $state.href('home.forward',{"url":$scope.platforms[0].url,"name":$scope.platforms[0].name,"dish_name":$scope.userSearchedDish});
With:
openurlnw = $state.href('home.forward',{"url":$scope.platforms[0].url,"name":$scope.platforms[0].name,"dish_name":$scope.userSearchedDish}, {absolute:true});
And Then:
$window.open(openurlnw,'_blank');
Upvotes: 4