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

Modals within ng-repeat creates a bunch of duplicate HTML #160

Closed
lightbody opened this issue Jun 2, 2013 · 6 comments
Closed

Modals within ng-repeat creates a bunch of duplicate HTML #160

lightbody opened this issue Jun 2, 2013 · 6 comments

Comments

@lightbody
Copy link

I have an app that iterates over a list of widgets and offers an "edit widget" link next to each one. I am using bs-modal to pop up a dialog box for editing each widget. This works fine, but I noticed that if I have N widgets I end up with N copies of the modal HTML.

I was hoping the $modal service would let me find a way to re-use the HTML, but I've had no such luck. Any suggestions?

Related to this, I can't really tell what the point of the Modal variable is that gets returned by $modal. It doesn't seem to have any functions on it, such as show() or hide() so it's not clear. Similarly, I don't see the point of passing in "show: false" on $modal, since if I don't show it I have no known way to show it later :)

@mgcrea
Copy link
Owner

mgcrea commented Jun 3, 2013

You should definitely use a service for this.
I'll try to update the docs soon to make it more clear.

@lightbody
Copy link
Author

Ah ha! I knew there had to be more to the story. Perfect, I'll use that for now, but yes maybe consider this "issue" to be a request to improve the discovery of this. Better docs is good, but actual functions is nice too because then I would have found them in the debugger :)

@mgcrea
Copy link
Owner

mgcrea commented Jun 5, 2013

@lightbody the $modal service returns a promise (since it may have to perform an http request to fetch the template. Proper usage is:

  var modalPromise = $modal({
    template: 'partials/modal.html',
    persist: true,
    show: false,
    backdrop: 'static',
    scope: $scope
  });
  $scope.showModalViaService = function() {
    $q.when(modalPromise).then(function(modalEl) {
      modalEl.modal('show');
    });
  };

I've updated the docs to make it more clear. Still we may want to pass another object when the promise is resolved.

@jaredwilli
Copy link

I think that's a good idea. ^

[decided to ask another modal question in a new issue since it's a bit more involved.]

@mgcrea
Copy link
Owner

mgcrea commented Jan 8, 2014

The AngularStrapv2.0.0-beta.1 has been released with a new version of this plugin. The former version is now both deprecated and unsupported.

Please try to reproduce your issue against the master branch.

Thanks!

@mgcrea mgcrea closed this as completed Jan 8, 2014
@lock
Copy link

lock bot commented Jan 27, 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 27, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 27, 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

3 participants