如何将自定义数据传递给角带模式

时间:2014-01-27 22:46:05

标签: angular-strap

我正在使用angular-strap的模态并构建了自己的模板。我的问题是我的模板有2个按钮,但是,我会更改这些按钮的文本和功能。因此,我想在打开它之前将该数据传递给模态。

在文档中说

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

然而,我无法让它发挥作用。请注意,我只想将一些值传递给模态范围,而不是我的整个父范围(这是示例似乎做的)

1 个答案:

答案 0 :(得分:6)

它不像ui-bootstrap那么简单,但看起来更灵活:

// 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'});