gpt4 book ai didi

angularjs - Angular + Webpack [$compile :tpload] Failed to load template

转载 作者:行者123 更新时间:2023-12-02 23:58:13 30 4
gpt4 key购买 nike

如果有人遇到这样的问题,请帮忙。

我使用 Angular + Webpack 并尝试使用 html-loader 向我的 JS 请求 HTML 文件。

首先,我的指令需要html文件

var templateUrl = require('./test.html');

然后我执行 webpack 命令,webpack 说一切都很好,并且捆绑所有文件没有任何问题。

然后我有一个错误(它在我的控制台中):

[$compile:tpload] Failed to load template: <div class="test">
<p>This is my TEST</p>
</div> (HTTP status: 404 Not Found)

据我了解,它看到了我的html,但在此之前它说无法获取它(模板),这是为什么?

网络中的请求

GET http://127.0.0.1:7773/portal/%3Cdiv%20class=%22test%22.....

例如成功需要:

Request URL:http://127.0.0.1:7773/portal/dev/bundle.js

据我了解,webpack 在另一个地方寻找它。如何解决?

有关我的完整路径的信息:

/home/darthjs/Documents/****/src/public/portal/app/components/navtop/test.html

最佳答案

使用template: require('./test.html')而不是templateUrl。根据您的指示:

{ // directive definition object
restrict: 'A',
template: require('./file.html')
}

关于angularjs - Angular + Webpack [$compile :tpload] Failed to load template,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34629683/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com