Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close in a single controller? #281

Open
alanapplyby opened this issue Sep 16, 2020 · 0 comments
Open

Close in a single controller? #281

alanapplyby opened this issue Sep 16, 2020 · 0 comments

Comments

@alanapplyby
Copy link

When the user clicks a button on my modal I want to call a function which applies some logic and then closes the modal, I want to use a single controller:

function MyController($scope, $http, $window, AlertService, vcRecaptchaService, ModalService, close) {

    $scope.agreeTerms = function() {    
        // some logic...
        close(true, 500); 
    }

    $scope.popModal = function(template, controller) {
        ModalService.showModal({
            templateUrl: template,
            controller: controller,
            preClose: (modal) => {modal.element.modal('hide');}
        }).then(function(modal) {
            modal.element.modal();
            modal.close;            
        });
    };

}

In my template:

ng-click="popModal('termsConditions', 'MyController')"

The button calls the agree terms funciton. At run time I get an error:

Unknown provider: closeProvider <- close <- MyController

I have seen other solutions and it requires using a separate modal controlleer, in my case I want to use one because the logic applied in my functon called by the button on the modal needs to be in the same scope as the original controller.

Is this possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant