jameskleeh / angular-confirm

Confirmation modal dialog for AngularJS
Apache License 2.0
150 stars 75 forks source link

Confirmation within another modal #18

Closed WillStrohl closed 8 years ago

WillStrohl commented 8 years ago

Do you have any examples of using this from within another modal? I'm still new to angular, so I may be missing something quite simple, but I'm getting an injection error after following your example.

I have a view that itself will open a modal to allow for data entry. It's a pretty standard setup... form fields, and clicking okay will save the information. Cancel will cancel everything.

There's set of fields that dynamically repeat and they each have a button that will delete a set, if needed. In that function, I'm using the service method of calling your plugin.

I've included the reference in my controller like your example says.

codeCampApp.controller("AddSpeakerModalController", ["$scope", "$rootScope", "$modalInstance", "$confirm", "codeCampServiceFactory", function ($scope, $rootScope, $modalInstance, $confirm, codeCampServiceFactory) {

And then I included the confirm within the OK click function.

$scope.RemoveSession = function (session) {

    if (session.SessionId > 0 || (session.Title.length > 0 || session.Description.length > 0)) {
        $confirm({ text: 'Are you sure you want to delete this session?' })
            .then(function () {
                if (session.SessionId > 0) {
                    // call a web service to delete the session server-side
                }

            return;
        });
    }

    var index = $scope.sessions.indexOf(session);
    $scope.sessions.splice(index, 1);
}

But I get this error when I click on the button to open the original (my) modal:

Error: [$injector:unpr] Unknown provider: $confirmProvider <- $confirm <- AddSpeakerModalController

image

Can you help me?

jameskleeh commented 8 years ago

Can you provide an example so I can reproduce the issue? Plunkr or equivalent

WillStrohl commented 8 years ago

Sorry. I ended up going another way and using a jQuery popup instead.