0

encouragementModal我只想在用户单击“鼓励”按钮时显示 modal( )。

配置

普惠制视图_encourage.gsp是:

<div ng-controller="EncouragementController">
    <g:if test="${notEncouraged}">
                           <button class="btn" ng-click="openEncouragementModal()">Encourage</button>
                           <div modal="encouragementModal" close="closeEncouragementModal()" options="opts">
                            <div class="modal-header">
                                <h3>Encourage!</h3>
                            </div>
                            <div class="modal-body">
                                    You are about to encourage with {{amount}}.
                            </div>
                            <div class="modal-footer">
                               <button class="btn btn-info cancel" ng-click="encourage()">Confirm</button>
                                <button class="btn btn-warning cancel" ng-click="close()">Cancel</button>
                            </div>
                        </div>
                    </g:if>
                    <g:else>
                          Thank you for encouraging.
                    </g:else>

EncouragementController.js是_

function EncouragementController($scope, $http) {
  /**
   * open payment dialog
   */
  $scope.openEncouragementModal = function (amount) {
        $scope.encouragementModal = true;
  };

  $scope.closeEncouragementModal = function () {
        $scope.closeMsg = 'You canceled the encouragement’;
        $scope.encouragementModal = false;
  };


  $scope.opts = {
        backdropFade: true,
        dialogFade:true
  };


}

EncouragementController.$inject = [ '$scope', '$http'];

问题

第一次应该只看到“鼓励”按钮,但我看到的是按钮以及encouragementModal它的按钮。

那么,我该怎么做呢?

我关注的参考文献

[1]模态(ui.bootstrap.modal)

[2]简单 Grails + AngularJS 示例

4

1 回答 1

0

您需要首先隐藏它,并且仅在 scope.encouragementModal 值为 true 时才显示它。

<div modal="encouragementModal" ng-show="encouragementModal" options="opts">
于 2013-08-30T17:14:50.437 回答