我想用"取消"关闭模态。按钮
在控制器中打开模态:
$scope.newTransaction = function(){
var modalInstance = $modal.open({
templateUrl: 'tpl/transactions/modal/new_transaction.html'
});
};
模态:
<div ng-controller="TransactionsCtrl">
<div class="modal-header bg-success">
<h3 class="modal-title">New Transaction</h3>
</div>
<div class="modal-body" style="height: 500px;">
<iframe ng-src="{{mylink_newTransaction}}" height="100%" width="100%" frameBorder="0">
</iframe>
</div>
<div class="modal-footer bg-light">
<button class="btn btn-default">Cancel</button>
<button class="btn btn-success">Create</button>
</div>
</div>
感谢您的帮助!
答案 0 :(得分:2)
<button ng-click="$close()">Cancel</button>
答案 1 :(得分:0)
只需添加data-dismiss
属性:
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
答案 2 :(得分:0)
documentation使用:ng-click="cancel()"
因此,在您的情况下,按钮应如下所示:
<button class="btn btn-default" ng-click="cancel()>Cancel</button>
plunker (来自相同文档)