Angular 用于绘制Html的类型脚本concat字符串
在Angular2V4中,我有一个包含多个项的数组。例如:Angular 用于绘制Html的类型脚本concat字符串,angular,string,typescript,concat,Angular,String,Typescript,Concat,在Angular2V4中,我有一个包含多个项的数组。例如: const array = ['1', '2', '3']; array.forEach(h => { this.htmlhistory.concat('hello <br>'); }); 因此,结果必须是: <div> hello <br> hello <br> hello <br> </div> 你好 你好 你好 但这不起作用。。。
const array = ['1', '2', '3'];
array.forEach(h => {
this.htmlhistory.concat('hello <br>');
});
因此,结果必须是:
<div>
hello <br>
hello <br>
hello <br>
</div>
你好
你好
你好
但这不起作用。。。我做错了什么?
是否有不使用*ngFor
的其他解决方案
我需要在component.ts文件中找到解决方案。。。不在html文件中
如果您希望在组件中呈现HTML,请提供帮助,您需要使用
[innerHTML]=“htmlhistory”
而不是{{}
语法
这是一个快捷的方法,以备您需要。而不是
<div>
{{ this.htmlhistory }}
</div>
{{this.htmlhistory}
用这个
<div [innerHTML]="htmlhistory">
</div>
它的作用是什么?有错误信息吗?
<div [innerHTML]="htmlhistory">
</div>