Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 用于绘制Html的类型脚本concat字符串_Angular_String_Typescript_Concat - Fatal编程技术网

Angular 用于绘制Html的类型脚本concat字符串

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> 你好 你好 你好 但这不起作用。。。

在Angular2V4中,我有一个包含多个项的数组。例如:

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>