点击按钮,我打开一个模态对话框:
<button type="button" data-toggle="modal" data-target="#openModal">Click</button>
<div class="modal fade" id="openModal"
tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
//modal body
</div>
我想知道是否有任何方法可以根据选择下拉菜单打开模态对话框?特别是使用javascript / angular js
答案 0 :(得分:1)
我没有完全发现这个问题。但是,你需要像this plunker这样的东西吗?
<script type="text/ng-template" id="modal1.html">
<div class="modal-header">
<h3 class="modal-title">Modal 1</h3>
</div>
</script>
<script type="text/ng-template" id="modal2.html">
<div class="modal-header">
<h3 class="modal-title">Modal 2</h3>
</div>
</script>
Select number of modal you'd like to open:
<select ng-model="form.selection">
<option value="modal1">Modal 1</option>
<option value="modal2">Modal 2</option>
</select>
<button class="btn btn-default" ng-click="open()">Open me!</button>
和
$scope.form = {
selection: "modal1"
};
$scope.open = function (size) {
var modalInstance = $modal.open({
templateUrl: $scope.form.selection + '.html',
controller: 'ModalInstanceCtrl'
});
};