【发布时间】:2017-01-07 02:46:50
【问题描述】:
我创建了一个按钮,当您单击它时会出现一个模式。 代码如下:
<li style="float: right;">
<button id="myBtn" data-target="#myModal" ng-click="printDivModal('rollup-tab')">Modal Test</button>
</li>
在 js 中,ng-click 应该打开一个模型,其中包含来自 stackModal.html 的数据 这是js文件中的代码:
$scope.printDivModal = function(divName) {
console.log('opening pop up');
var ModalInstance = $uibModal.open({
//animation: $ctrl.animationsEnabled,
templateUrl: 'app/views/modals/stackedModal.html',
size: 'lg',
/*
controller: function($scope) {
$scope.name = 'top';
}
*/
});
}
这是模型的代码(stackedModal.html):
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">The Modal Header</h4>
</div>
<div class="modal-body">
<p>Text inside the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
当我单击模型测试按钮时,我看到的只是屏幕上显示的一个白色小矩形。 stackedModal html 页面中没有显示任何内容。为什么是这样?谢谢。
【问题讨论】:
-
您是否在控制台中收到“正在打开弹出窗口”的消息?
-
@StefanVilbrandt 是的,我愿意
-
使用javascript模型打开时也不需要data-target属性。
标签: html angularjs angular-ui-bootstrap bootstrap-modal angularjs-ng-click