Angularstrap Modal not show content when click open with $modal service twice
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!
Please provide a reproducible test-case from this working plunker: http://plnkr.co/edit/xKP5PW3Dco1CczmCuuVN?p=preview
Feel free to reopen when its done.
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 }}".
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.
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:
- The modal expressions are not evalutated.
- The other button stops working.
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();
});
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
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.
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');
});
});
}
};
}]);
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
Solved: the anchor in the plunker which triggers the modal opening via service should not have href="#".
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.
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.