【问题标题】:AngularJS ui.bootstrap.modal templateUrl not working correctlyAngularJS ui.bootstrap.modal templateUrl 无法正常工作
【发布时间】:2017-03-13 17:58:10
【问题描述】:

我正在尝试连接一个 ui.bootstrap.modal 对象来显示一些数据,我决定创建一个单独的 html 文件来保存我对模态的所有标记。我可以看到某些模式尝试打开,因为屏幕显示为灰色。但是,在控制台中,我可以看到我收到 404 错误,尽管不在我打算用于我的模板的文件上。

编辑- 我可能已经解决了我的问题。在此模块的配置级别,我添加了 ui.bootstrap.modal。将其更改为 ui.bootstrap 后一切正常。

唯一的问题是我的模态显示在屏幕的左上角?

打开模态的代码:

function openModal() {
 $uibModal.open({
 templateUrl: '../Pages/Views/Templates/emailListingView.html',
 controller: function ($scope) { }
 });
};

我的 HTML 模板:

<div>
<div class="modal-header">
    <h3 class="modal-title" id="modal-title">I'm a modal!</h3>
</div>
<div class="modal-body" id="modal-body">
    <ul>
        <li>Bruh</li>
    </ul>
</div>
<div class="modal-footer">
    <button class="btn btn-primary" type="button">OK</button>
    <button class="btn btn-warning" type="button">Cancel</button>
</div>

角度错误:

错误:$compile:tpload 加载模板时出错

错误窗口:

加载资源失败:服务器响应状态为404()https://localhost:44375/uib/template/modal/window.html

【问题讨论】:

  • 这条路对吗?
  • 是的,非常正确的路径。
  • 我担心我的解决方案甚至没有 /uib/template/modal/window.html 文件?
  • 您可能没有使用正确的 ui-bootstrap JS 文件。确保使用包含模板的模板(以 tpls.js、IIRC 结尾)。如果有疑问,请发布包含
  • 好吧,这是有道理的,所以当它说下载时,我需要在他们的网站上使用带有模板的那个。这是我第一次使用 Angular UI 指令。

标签: angularjs angular-ui-bootstrap


【解决方案1】:

您需要确保并使用ui-bootstrap-tpls.min.js 文件。这就是支持使用&lt;script&gt; 模板的原因。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-03
    • 2018-05-09
    相关资源
    最近更新 更多