Show default browser popup in AngularJS application

Standard
$scope.showPopup = function showPopup() {
    var popup = $window.open('/PagePath/ViewName', '',
                "height=560,width=1175,status=yes,toolbar=no,
                 menubar=no,location=no"), interval = 1000;
 
    var i = $interval(function () {
        interval += 500;
        try {
            if (popup.value) {
                $interval.cancel(i);
                popup.close();
            }
        } catch (e) {
            console.error(e);
        }
    }, interval);
}

 

P.S. Please note you have to inject $window in controller/service/factory or in module initialization before using above code.

Advertisements

One thought on “Show default browser popup in AngularJS application

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s