Javascript 如何将动态模板加载到$uibModal.open()(角度UI引导)中?

Javascript 如何将动态模板加载到$uibModal.open()(角度UI引导)中?,javascript,angularjs,angular-ui-bootstrap,Javascript,Angularjs,Angular Ui Bootstrap,我使用的是AngularUI引导。我想定义一个通用模式窗口,以提供一些默认按钮,如关闭、确定、标题等 用户的模态主体模板作为模板url提供。如何将用户的模态体模板合并到通用模态窗口模板中 下面是我的通用模态窗口模板, modal-window.tpl.html <div class="modal-header"><h3>{{ ctrl.headerText }}</h3></div> <div class="modal-body">

我使用的是AngularUI引导。我想定义一个通用模式窗口,以提供一些默认按钮,如关闭、确定、标题等

用户的模态主体模板作为模板url提供。如何将用户的模态体模板合并到通用模态窗口模板中

下面是我的通用模态窗口模板, modal-window.tpl.html

<div class="modal-header"><h3>{{ ctrl.headerText }}</h3></div>

<div class="modal-body">


    <<<< The user's template provided as URL should be embedded in here >>>


</div>

<div class="modal-footer">
  <button type="button" class="btn" data-ng-click="ctrl.close()"> {{ctrl.closeButtonText}} </button>
  <button class="btn btn-primary"   data-ng-click="ctrl.ok();"> {{ctrl.actionButtonText}}</button>
</div>
{{ctrl.headerText}

您应该能够为此使用
ng include
。 如果将用户模板url放在控制器的作用域上:
userTemplate='users/template.html'
。然后你可以做一些类似的事情:

...
<div class="modal-body">
    <div ng-include="ctrl.userTemplate"></div>
</div>
...
。。。
...
如果您还需要自定义控制器,可以这样定义:

用户/template.html

<div ng-controller="CustomModalController as modalCtrl">
    {{modalCtrl.foo}}
</div>

{{modalCtrl.foo}}

唯一的缺点是需要在父控制器中定义此控制器。在本例中,控制器被定义为
userTemplate='users/template.html'

很好的解决方案,但是自定义控制器呢?编辑了本例的答案这非常适合我的用例!谢谢