Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Angularstrap Modal not show content when click open with $modal service twice #158

Closed
sangnv opened this issue Jun 1, 2013 · 12 comments
Closed

Comments

@sangnv
Copy link

sangnv commented Jun 1, 2013

I found a problem in the overview and example of Modal popup. When I click the first time the modal popup is show the content correctly "Hello Modal", but when I click the second times the content was show wrong "{{modal.content}}". Can any one help me to fix this problem. Thanks in advance!

@mgcrea
Copy link
Owner

mgcrea commented Jun 2, 2013

Please provide a reproducible test-case from this working plunker:
http://plnkr.co/edit/xKP5PW3Dco1CczmCuuVN?p=preview

Feel free to reopen when its done.

@mgcrea mgcrea closed this as completed Jun 2, 2013
@sirbarrence
Copy link

I see the issue reproduced in the aforementioned plunker already, but only for the service button. The first time you click the "With $modal Service" button, you see "Hello Modal" and "2 + 3 = 5". If you click "Close" then click "With $modal Service" again, you see "{{modal.content}}" and "2 + 3 = {{ 2 + 3 }}".

@sirbarrence
Copy link

If I pass a new scope to $modal() every time - using $rootScope.$new() - I don't have the problem. If I pass my controller's $scope as the scope parameter to $modal() - as inside $scope.viaService() in the example plunker - it fails to bind to the template the second time.

@mgcrea mgcrea reopened this Jun 3, 2013
@dogweather
Copy link

The problem is visible on the AngularStrap site: http://mgcrea.github.io/angular-strap/#/modal.

To reproduce: Click the With $modal service button twice.

Results:

  1. The modal expressions are not evalutated.
  2. The other button stops working.

@protoze
Copy link

protoze commented Jun 5, 2013

There is an option called persist that is visible from the source, without it the scope is destroyed.

            $modal.on('hidden', function (ev) {
                if (!options.persist)
                    scope.$destroy();
            });

@ljovner
Copy link

ljovner commented Aug 26, 2013

mgcrea...awesome job with Angular Strap!!

I just ran into the same issue...and it still seems to exists...and still reproducible on the main site.

Any idea on when it might get fixed?

Thanks

@timgautier
Copy link

I just ran into this also from the code on the main site. It took more than a couple clicks of the "With $modal service" button before it stopped working, but it did eventually. I wish I could say exactly what I did, but I was just playing around with those two buttons and I'm not sure how many times I clicked what before it stopped working. It also stopped the other button from functioning.

EDIT: Opening the plunker for modals from the main site also causes the issue. 2nd click of the button and it no longer works.

@ProdigyView
Copy link

I also have the same problem. My code example is below:

EngagementApp.directive('profileModal', ['$compile', 'Request', '$modal', '$q',
function($compile, Request, $modal, $q) {

return {
    restrict : 'A',
    link : function(scope, element, attrs) {
        var modalPromise = null;
        element.bind('click', function(e) {
            e.preventDefault();
            scope.modal = {
                username : attrs.profileModal,
                url : main_site_url
            };

            modalPromise = $modal({
                template : '/templates/profile_modal.html',
                persist : false,
                show : false,
                backdrop : 'static',
                scope : scope
            });
            //console.log('Create Promise');
            //console.log(modalPromise);
            $q.when(modalPromise).then(function(modalEl) {

                modalEl.modal('show');
            });

        });

    }
};

}]);

@ericmedvet
Copy link

I have a similar problem when the modal is created using the service from a controller which is not on the root scope (e.g., a controller of a routing view): the modal content is not evaluated ({{1+1}} is shown as {{1+1}}).
See this example: http://plnkr.co/edit/Ep5l2CLM4npjVSDP3c4d?p=preview

@ericmedvet
Copy link

Solved: the anchor in the plunker which triggers the modal opening via service should not have href="#".

@JavaBasketball
Copy link

you should remove ng-show="title" , ng-show="content" or ng-bind="title" from the template. You should make sure that the template has no ng-show.

@lock
Copy link

lock bot commented Jan 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the outdated label Jan 26, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants