我试图在newtab中打开一个状态但是无法实现它。我这样做是使用$ state,go function。
我也尝试了以下代码,这是成功的,并在newtab中打开我的网址,但浏览器阻止在新标签中打开新网址。
openurlnw = $state.href('home.forward',{"url":$scope.platforms[0].url,"name":$scope.platforms[0].name,"dish_name":$scope.userSearchedDish});
window.open(openurlnw,'_blank');
我想在新标签页中打开状态,而不让浏览器阻止它。
答案 0 :(得分:2)
您必须在构建网址时使用absolute
选项,然后使用$window.open
替换:
openurlnw = $state.href('home.forward',{"url":$scope.platforms[0].url,"name":$scope.platforms[0].name,"dish_name":$scope.userSearchedDish});
使用:
openurlnw = $state.href('home.forward',{"url":$scope.platforms[0].url,"name":$scope.platforms[0].name,"dish_name":$scope.userSearchedDish}, {absolute:true});
然后:
$window.open(openurlnw,'_blank');