【问题标题】:how to find html file in ngDialog template with webpack?如何使用 webpack 在 ngDialog 模板中查找 html 文件?
【发布时间】:2016-02-26 19:11:03
【问题描述】:

您好,我在尝试使用 webpack 捆绑我的文件和 ngDialog 以使弹出窗口正常工作时遇到问题。弹出窗口只会显示“你好!”立即留言。

这是我的功能:

function popupEditOptions(){
    ngDialog.open({
        template: 'src/req/edit/editOptions.html',
        scope: $scope
    });
};

当我这样做时,我得到一个错误:
GET http://localhost:3000/src/req/edit/editOptions.html 404(未找到)

我可以像这样要求 html 文件:

function popupEditOptions(){
    ngDialog.open({
        template: require('src/req/edit/editOptions.html'),
        scope: $scope
    });
};

但现在我收到了写出 html 文件内容的错误:
获取http://localhost:3000/Hello! 404(未找到)

【问题讨论】:

  • 您缺少 editOptions.html 的路径。查看并更正它。
  • 文件路径正确src/req/edit/editOptions.html。它甚至显示在第二个错误中。
  • 你的 index.html 文件的路径是什么(ng-app 是在哪里定义的).
  • 根目录下

标签: javascript html angularjs webpack ng-dialog


【解决方案1】:

看来可能是ngDialog的bug,参考这个github问题:https://github.com/likeastore/ngDialog/issues/390

但您可以使用 plain:true 属性使其工作。

ngDialog.open({
   plain: true,
   template: require('src/req/edit/editOptions.html'),
   scope: $scope
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-30
    • 2017-12-01
    • 2020-05-28
    • 1970-01-01
    • 2023-04-01
    • 2021-05-25
    • 1970-01-01
    • 2017-08-15
    相关资源
    最近更新 更多