我正在使用AngularUI 0.8.0(带有bootstrap 2.3)并试图获得一个简单的模式框来显示。
使用下面的代码,当我按下Open,模板和控制器加载时,显示警报,db从$ modal.open接收承诺,然后模板呈现在现有页面的底部 - 未打开模态对话框。
这会导致什么?我该如何排除故障?
提前致谢!
<!-- ConfirmPage.cshtml -->
<button class="btn btn-primary" ng-click="ctrl.openModal()">Open</button>
控制器是:
<!-- ConfirmPageCtrl.coffee -->
class ConfirmPageCtrl
constructor: (@$scope, @$modal) ->
$scope.ctrl = @
openModal: () =>
alert 'Called modal.open'
db = @$modal.open
templateUrl: '/Home/ConfirmTpl'
controller: 'ModalCtrl'
db.result.then @modalOk, @modalCancel
modalOk: () ->
alert 'I am OK!'
modalCancel: () ->
alert 'I have been cancelled :-('
class ModalCtrl
constructor: (@$scope, @$modalInstance) ->
ok: () =>
@$modalInstance.close()
cancel: () =>
@$modalInstance.dismiss()
app.controller 'ConfirmPageCtrl',
['$scope', '$modal', ConfirmPageCtrl]
app.controller 'ModalCtrl',
['$scope', '$modalInstance', ModalCtrl]