【问题标题】:AngularJS Bootstrap Modal - Change template onclick()?AngularJS Bootstrap Modal - 更改模板 onclick()?
【发布时间】:2017-08-29 20:49:04
【问题描述】:

我目前有两个单独的模式。单击按钮时,将加载第一个模式。如果在此模式中单击特定按钮,我想加载不同的模式。但是,与其让模态之间发生短暂的闪烁,我想知道是否有一种简单的方法可以使用当前模态但更改其中的模板?

【问题讨论】:

    标签: angularjs modal-dialog angular-bootstrap


    【解决方案1】:

    有几种方法可以做到这一点。我会解释后者,因为它更简单

    • 使用 ngRoute
    • 使用ng-showng-if

    所以在你的模态中格式化 HTML,如下所示:

    <modal>
        <div ng-if="modal == 'one'">
            ... modal one content
        </div>
        <div ng-if="modal == 'two'">
            ... modal two content
        </div>
    </modal>
    

    然后在你的控制器中:

    $scope.onClickSecondModalButton = () => {
        $scope.modal = 'two'
    }
    

    您可以通过将$scope.modal 更改为'one''two',在没有动画闪烁的情况下在两个模式之间切换。

    【讨论】:

      猜你喜欢
      • 2017-04-01
      • 2021-07-27
      • 1970-01-01
      • 1970-01-01
      • 2015-09-28
      • 2015-07-11
      • 2020-12-06
      • 2014-04-08
      • 1970-01-01
      相关资源
      最近更新 更多