How to pass custom data to an angular-strap modal
Asked Answered
D

1

6

I am using angular-strap's modal and have built my own template. My issue is that my template has 2 buttons, however, I the text and functionality of these buttons will change. As a result, I would like to pass on that data to the modal before I opened it.

In the documentation it says

// Pre-fetch an external template populated with a custom scope
  var myOtherModal = $modal({scope: $scope, template: 'modal/docs/modal.tpl.demo.html'});

However, i haven't been able to get it working. Note that I would only like some values passed to the modal scope, not my entire parent $scope (which is what the example seems to do)

Distended answered 27/1, 2014 at 22:46 Comment(0)
H
6

It's not as straightforward as in ui-bootstrap but it looks more flexible:

// creates new isolated scope
var myNewScope = $scope.$new(true);
// then you can data to your new scope
myNewScope.users = ["User1", "User2", "User3"];
var myOtherModal = $modal({scope: myNewScope, template: 'modal/docs/modal.tpl.demo.html'});
Hypoderma answered 26/8, 2014 at 7:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.