【问题标题】:How to pass custom data to an angular-strap modal如何将自定义数据传递给 angular-strap 模态
【发布时间】:2014-01-27 22:46:04
【问题描述】:

我正在使用 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'});

但是,我无法让它工作。请注意,我只希望将一些值传递给模态范围,而不是我的整个父 $scope(这就是示例似乎要做的)

【问题讨论】:

    标签: angular-strap


    【解决方案1】:

    它不像 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'});
    

    【讨论】:

      猜你喜欢
      • 2014-07-17
      • 2012-08-17
      • 1970-01-01
      • 2018-05-18
      • 2015-04-12
      • 1970-01-01
      • 2019-07-08
      • 2017-06-15
      • 2018-08-05
      相关资源
      最近更新 更多