0

In Angular2 v4 I have an array with multiple items. For example:

const array = ['1', '2', '3'];
array.forEach(h => {
  this.htmlhistory.concat('hello <br>');
});

the htmlhistory item is a string

and in my html component I have this:

<div>
  {{ this.htmlhistory }}
</div>

So the result have to be:

<div>
  hello <br>
  hello <br>
  hello <br>
</div>

BUT this doesn't works... What I'm doing wrong? Is there anothes solution without using *ngFor?

I need a solution in the component.ts file ... not in the html file

Please help

1
  • What does it do? Any error messages? Commented Sep 25, 2018 at 22:40

2 Answers 2

1

Instead of

<div>
  {{ this.htmlhistory }}
</div>

Use this

<div [innerHTML]="htmlhistory">
</div>
Sign up to request clarification or add additional context in comments.

Comments

0

If you want to render HTML in your component you are expected to use [innerHTML]="htmlhistory" not {{}} syntax.

Here is a quick example, in case you needed it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.