Coder Social home page Coder Social logo

Comments (1)

m-e-conroy avatar m-e-conroy commented on August 22, 2024

Thanks, sorry for the late reply, just trying to catch up after a long vacation.

Thats not really a function of the dialog. I understand what you're trying to do, I think in this instance the object returned by the modal instance is out of scope of the event, also if this is a link it may have left the page already before the promise is returned. The "confirm" that is allowing you to stop navigation is a function of the browser itself and will pause events waiting for a response, the in page dialog doesn't do this since it works as a JS promise.

I think what you want to do is something like this:

<a class="btn btn-default" ng-click="navigate('http://so.me/url')">Go Some Where</a>

then inside your controller:

var _unsavedFlag = true;

$scope.navigate = function(url){
    if(_unsavedFlag){
        var dlg = dialogs.confirm("Please Confirm","Warning, Leave without saving?");
        dlg.result.then(function(){ // yes
            $window.location.href = url;  // leaves without saving.
        },function(){ // no
            // do some saving
        });
    }
};

Of course you'll have to set _unsavedFlag some how when your $scope models change.

Again sorry for the late reply, hopefully you found a solution in the meantime.

from angular-dialog-service.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.