Sarath
Sarath

Reputation: 1499

ngDialog Close Button redirect To other page

I am developing application using AngularJs for popup i am using ngDialog. One of my requirement is.Once we close the ngDialog popup.I need to redirect the current page to home page.

My code :

ngDialog.open({
                template:'<div style="margin-top:10px;" >Please try after some time.</div>',
                plain:true,
                closeByEscape : false,
                closeByDocument : false
            });

Is it possible?

Upvotes: 0

Views: 1037

Answers (2)

alexsc
alexsc

Reputation: 1216

Hei, you can try to use the preCloseCallback in order to redirect to your desired page (home page). For this you'll need $window as injection and you can use it like this :

preCloseCallback: function(value) {
       var url = "#/home" // or whatever the route is
       $window.location = url
       return true
     }

Hope it'll help. Best!

Upvotes: 3

Croot
Croot

Reputation: 331

var dialog = ngDialog.open({
    template: 'templateId'
});

dialog.closePromise.then(function (data) {
    window.location.replace("http://stackoverflow.com");
});

Upvotes: 0

Related Questions