Search code examples
javascriptangularjsmeanjs

Close window before loading Angular modules (after authentication)


I'm having my users authenticate with Facebook in a separate window so that I don't need to refresh the web app.

I have the redirect go to a route with an HTML file that simply calls window.close()

Unfortunately, the HTML file containing window.close() only loads after all the Angular modules have downloaded in the window.

Is there a way to close the window immediately, before loading all these modules?


Solution

  • You will have to have a script at the top and parse out the route before angular is loaded instead of depending on the angular router.

    getUrlParameter from here

    <script type="text/javascript">
    function getURLParameter(name) {
      return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null;
    }
    if(getURLParameter(close)){
       window.close();
    }
    </script>
    .....angular stuff after ....