Raaj Dubey
Raaj Dubey

Reputation: 182

How to open $state,go() in new tab

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

Answers (1)

Anadi Sharma
Anadi Sharma

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

Related Questions