2

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.

Raaj Dubey
  • 172
  • 1
  • 14

1 Answers1

4

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');
Anadi Sharma
  • 295
  • 1
  • 8
  • this is still not working .. same error browser prevented this site to open new pop-up window – Raaj Dubey Mar 06 '17 at 09:34
  • 1
    Actually, this is a functionality in all browsers. Specifically, to avoid opening multiple popups, maybe in a loop. You should open the popup window only after a user action, and it won't be blocked. – Anadi Sharma Mar 06 '17 at 09:40