Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close browser window in AngularJS

Tags:

angularjs

I have a login form that is popped up as a separate browser window. Once the API validates that the user is logged in, how do I close that login browser window in AngularJS?

like image 260
julie-coderiver Avatar asked Sep 27 '13 01:09

julie-coderiver


2 Answers

Use $window.close() in $window service.
You can broadcast the result to another controller like this AngularJS – Communicating Between Controllers

like image 102
dohaivu Avatar answered Sep 28 '22 08:09

dohaivu


This will first prompt the user, asking them whether they want to close their browser:

$window.close()

You'll want to inject the $window service into your controller/service. You can also use the global javascript variable window directly, but I prefer to do it the "angular" way and only use injectables.

like image 20
Chris Montgomery Avatar answered Sep 28 '22 08:09

Chris Montgomery