Javascript 创建一个可重用的对话框模板

Javascript 创建一个可重用的对话框模板,javascript,angularjs,ng-dialog,Javascript,Angularjs,Ng Dialog,我想为我的应用程序创建一个可重用的模板 据我所知,您不能将标题和正文传递给ngDialog 我需要的是这样的东西: <div> <h2>{{ TITLE }}</h2> <- Dynamically pass this value {{ BODY }} <- Dynamically pass this value <div class="ngdialog-buttons"> <button type="b

我想为我的应用程序创建一个可重用的模板

据我所知,您不能将标题和正文传递给ngDialog

我需要的是这样的东西:

<div>
<h2>{{ TITLE }}</h2> <- Dynamically pass this value
{{ BODY }} <- Dynamically pass this value

    <div class="ngdialog-buttons">
        <button type="button" class="ngdialog-button ngdialog-button-secondary" ng-click=closeThisDialog("Cancel")>Cancel</button>
        <button type="button" class="ngdialog-button ngdialog-button-primary" ng-click=confirm("OK")>OK</button>
    </div>
</div>
我如何做到这一点?这样,我可以在我的应用程序中使用相同的html文件


编辑:我在爱奥尼亚/科尔多瓦也有同样的项目,爱奥尼亚更容易。我想知道为什么使用angular这么难。

在同一控制器中使用行为将允许您访问模型,并且您将能够更改标题和正文

在同一控制器中使用行为将允许您访问模型,并且您将能够更改标题和正文

            ngDialog.openConfirm({
              template: 'views/alertTemplate.html'
            });  
并在视图文件夹中放入alertTemplate.html文件:

例如:

<div class="alert-dialog-container">
  <div class="alert-dialog-body">
    Hello my dialog!
  </div>
  <div class="alert-dialog-footer">
    <button ng-click="confirm()">OK</button>
  </div>
</div>

你好,我的对话!
好啊
并在视图文件夹中放入alertTemplate.html文件:

例如:

<div class="alert-dialog-container">
  <div class="alert-dialog-body">
    Hello my dialog!
  </div>
  <div class="alert-dialog-footer">
    <button ng-click="confirm()">OK</button>
  </div>
</div>

你好,我的对话!
好啊

这是推荐的方式吗?或者推荐的方法是创建单独的html模板文件?这是推荐的方法吗?或者推荐的方法是创建单独的html模板文件?