我使用角度材料$ mdDialog服务打开一个对话框。 当用户点击确定按钮时,我想打开一个新标签并导航到另一个网址。
问题是,浏览器弹出窗口阻止程序(在chrome / safari上测试)阻止打开新选项卡,因为操作是间接来自用户的点击(据我所知)。
我正在使用网站上的$ mdDialog示例:
$scope.showConfirm = function(ev) {
var confirm = $mdDialog.confirm()
.title('Would you like to delete your debt?')
.textContent('All of the banks have agreed to forgive you your debts.')
.ariaLabel('Lucky day')
.targetEvent(ev)
.ok('Please do it!')
.cancel('Sounds like a scam');
$mdDialog.show(confirm).then(function() {
$scope.status = 'You decided to get rid of your debt.';
$window.open('http://www.google.com', '_blank'); // <--- this is blocked
}, function() {
$scope.status = 'You decided to keep your debt.';
});
};