简体   繁体   English

在templateURL中找不到Angular 4图像但在模板字符串中有效

[英]Angular 4 image not found in templateURL but works in template string

I'm using the Angular 4 universal starter https://github.com/ng-seed/universal 我正在使用Angular 4通用启动器https://github.com/ng-seed/universal

I'm having an issue with the templateURL finding images even though they render fine just using: 我遇到了templateURL查找图像的问题,即使它们只是使用以下方式渲染:

template: '<img src="assets/img/twitter.png" />

When I put the same code in the templateURL: './home.component.html' I get: 当我在templateURL中输入相同的代码时:'。/ home.component.html'我得到:

Module not found: Error: Can't resolve './assets/img/twitter.png'

Not sure how to troubleshoot this one. 不知道如何解决这个问题。 The template renders all other HTML fine, but can't locate any images. 该模板呈现所有其他HTML正常,但无法找到任何图像。 Any idea how to solve would be great. 任何想法如何解决都会很棒。 thanks. 谢谢。

Angular指向src / assets文件夹

'<img src="/assets/img/twitter.png" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到业力角度templateUrl - karma angular templateUrl not found Angular2:模板工作,但templateUrl没有 - Angular2: template work, but templateUrl not 在angular中使用templateUrl刷新模板 - Refresh template using templateUrl in angular 使用组件将Angular模板替换为templateUrl - Replace Angular template with templateUrl using Components 使用templateUrl时,Angular编译器返回错误:为component指定的模板不是字符串 - Angular compiler returns error when using templateUrl: The template specified for component is not a string AngularJS 指令:“templateUrl”不起作用而“template”起作用 - AngularJS directive: "templateUrl" doesn't work while "template" works AngularJS:templateUrl适用于HTML模板文件,但不适用于.JSP - AngularJS: templateUrl works for a HTML template file, but it doesn't with a .JSP 根据用户输入在Angular Directive中设置模板或templateUrl - Setting template or templateUrl in Angular Directive based on user input 嵌套的角度指令与`template`与`templateUrl`的行为不同 - Nested Angular Directive behaving differently with `template` vs. `templateUrl` Angular指令错误:无法从templateUrl加载模板-当我通过“ templateUrl”加载模板时失败(在浏览器中连续加载) - Angular directive error : Unable to load template from templateUrl - fails when I load template via 'templateUrl' (continuous loading in browser)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM