javascript - Angular: always get popup blocker on create new tab after async call -
i have following scenario:
- user tries login wrong password
- on failure ask him if wants reset password
- if user click 'ok' (pure
confirm dialog
) , i'll open new tab url.
my problem is: i popup blocker because generate window
after error callback. here relevant code login
method:
$scope.login = function () { $auth.login({ email: $scope.fields.email, password: $scope.fields.password }) .then(function () { // ... login success }) .catch(function () { // login failed (my case) if (confirm('error: invalid password, forgot password? click \'ok\' if want reset it')){ var url_ = 'http://meeter.me/#/forgot-pass/snaggs@gmail.com'; var mypopup = window.open ('', '_blank'); mypopup.location = url_; if (mypopup && mypopup.focus) { mypopup.focus(); } }// if }); };
if move var mypopup = window.open ('', '_blank');
next line under $scope.login = function ()
work open new empty tab.
i want open new tab when error on login
i use satellizer
please help,
in demo use single $timeout
simulate async call
i don't think going possible open new window using window.open if invoked asynchronously. without user invocation, call stack going identify window.open triggered asynchly , going block it. maybe option show new button if login failed , let button open new window?
http://plnkr.co/edit/qgfnxh484odtvaaovmae?p=preview
<button ng-click="init();">press me</button><br /> <span ng-show="resetpwd" > login failed!! <button ng-click="reset()">reset password</button> </span> $scope.init = function() { $timeout(function() { $scope.resetpwd = true; }, 2000); }
Comments
Post a Comment