[英]how to integrate a html template in angular 7 project
I'm integrating a html template in angular 7 project and it is not working correctly我在 Angular 7 项目中集成了一个 html 模板,但它无法正常工作
I added the template files under assets/template/.. and i added the imports in angular.json like:我在 assets/template/.. 下添加了模板文件,并在 angular.json 中添加了导入,例如:
I edited the html code:我编辑了html代码:
(like src="/assets/template/img/slider/1.jpg" alt="main slider" title="#htmlcaption1") (比如 src="/assets/template/img/slider/1.jpg" alt="main slider" title="#htmlcaption1")
I added the html code in index.html under the app-root tag and all working fine我在 index.html 的 app-root 标签下添加了 html 代码,一切正常
But when i change it to app.component.html:但是当我将它更改为 app.component.html 时:
and I don't have any error in my console我的控制台没有任何错误
I usually don't use styles array in angular.json, Instead, I import all global styles in styles.css as it is set into angular.json styles array by default.我通常不在 angular.json 中使用样式数组,而是在 styles.css 中导入所有全局样式,因为它默认设置为 angular.json 样式数组。
/* You can add global styles to this file, and also import other style files */
@import "assets/quote.css";
@import "https://fonts.googleapis.com/css?family=IBM+Plex+Sans+Condensed:200|Josefin+Sans:300|Julius+Sans+One|Merriweather+Sans:400|Overpass:400|Quicksand"
Just add encapsulation: ViewEncapsulation.None
in @component
like below mentioned.只需在 @component 中添加
encapsulation: ViewEncapsulation.None
@component
所述。
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
encapsulation: ViewEncapsulation.None
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.