无法在gulp dist build上加载模板

时间:2016-03-10 05:28:31

标签: angularjs angularjs-directive gulp

我们使用的指令允许用户输入他们的出生日期。这在本地gulp dev构建中完全正常,但是当我们移动到分发构建时,它说无法找到此模板。在本地开发构建中使用该指令时,gulp:dist进程或控制台中的错误没有错误

以下是dist build

的错误消息
RequestHeaderPreAuthenticatedProcessingFilter

有具体原因吗?似乎无法在文件中找到任何无效的JavaScript。

指令很长,所以没有把它包含在这里。这是第一部分:

GET http://localhost:3000/app/_common/form-dob/form-dob.tpl.html 404 (Not Found)(anonymous function) @ generated.js:20178l @ generated.js:62054v @ generated.js:19971c @ generated.js:19681u @ generated.js:24202(anonymous function) @ generated.js:24218h.$eval @ generated.js:25462h.$digest @ generated.js:25280h.$apply @ generated.js:25570o @ generated.js:20002g @ generated.js:20200w.onload @ generated.js:20141
generated.js:21933 Error: [$compile:tpload] Failed to load template: /app/_common/form-dob/form-dob.tpl.html (HTTP status: 404 Not Found)
http://errors.angularjs.org/1.4.9/$compile/tpload?p0=%2Fapp%2F_common%2Fform-dob%2Fform-dob.tpl.html&p1=404&p2=Not%20Found
    at generated.js:9279
    at s (generated.js:27164)
    at u (generated.js:24202)
    at generated.js:24218
    at h.$eval (generated.js:25462)
    at h.$digest (generated.js:25280)
    at h.$apply (generated.js:25570)
    at o (generated.js:20002)
    at g (generated.js:20200)
    at XMLHttpRequest.w.onload (generated.js:20141)

1 个答案:

答案 0 :(得分:2)

问题是templateUrl在开头有/并导致问题

这是破碎的:

templateUrl: "/app/_common/form-dob/form-dob.tpl.html"

这是固定的:

templateUrl: "app/_common/form-dob/form-dob.tpl.html"