我正在使用角度ui引导程序。我想定义一个通用的“模态窗口”以提供一些默认按钮,例如关闭,确定,标题等。
用户的模态主体模板作为模板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>
谢谢。
您应该可以使用ng-include
它。如果您将用户模板网址放在控制器中的范围内:userTemplate='users/template.html'
。然后,您可以执行以下操作:
...
<div class="modal-body">
<div ng-include="ctrl.userTemplate"></div>
</div>
...
如果还需要自定义控制器,则可以这样定义:
users / template.html:
<div ng-controller="CustomModalController as modalCtrl">
{{modalCtrl.foo}}
</div>
唯一的缺点是需要在父控制器中定义此控制器。在这种情况下,userTemplate='users/template.html'
定义了控制器。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句