Code Monkey home page Code Monkey logo

Comments (2)

jtdevos avatar jtdevos commented on May 25, 2024

Had a similar concern but my thought was that it might be convenient to pass the modal in the catch callback, e.g.

ModalService.showModal({
    // pretend this template has a conditional div that displays any errors
    templateUrl: "some/template.html",
    // pretend this controller has an 'errorMessages' array
    controller: "SomeController"  
}).then(function(modal){
    // called on success...
}).catch(function(error, modal){
    modal.controller.errorMessages.push("Oh dear, this happened: " + error);
})

In lieu of such a feature, my approach was to pass an errorMessages closure into the showModal() 'inputs' option, and then update it in the catch callback, but I haven't confirmed whether that would work.

from angular-modal-service.

dwmkerr avatar dwmkerr commented on May 25, 2024

@robhicks @nobodyman the catch function should only be hit when something mechanistic fails, which means that in all likelihood we cannot expect the modal to be in a state where we can update it with error information. I would probably aim for handling this in the application like so:

ModalService.showModal({
templateUrl: "some/template.html",
controller: "SomeController"
}).then(function(modal) {
// only called on success...
}).catch(function(error) {
AlertService.showError("Something went wrong");
});

the AlertService would be defined by the app, it could show an alert, a modal, log or whatever. But assuming that we can actually somehow interact with the modal is probably wrong because we know that we have failed to create it. Thoughts?

from angular-modal-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.