2

I'm new to Ionic/Angular. I need to print an array with some HTML in it

{
"code" : "06",
"descr" : "Some text:</br>Other text.<br/>Other text</br>Other text."
}

But it doesn't go to a new line, it prints even the tag in my page instead. There's a way to avoid this?

I've read something about ng-bind-html-unsafe but apparently has been removed from angular.

2
  • maybe ng-bind-html? Commented Nov 26, 2019 at 19:24
  • Does this answer your question? Angular HTML binding Commented Nov 26, 2019 at 19:34

1 Answer 1

4

Try to use innerHtml:

<ng-container *ngFor="let item of yourArray">
    <div [innerHTML]="item.descr"></div>
</ng-container>
Sign up to request clarification or add additional context in comments.

2 Comments

@downvoter what's reason to downvote? It would be really helpful to me to improve my answer
@WilliamManzato I am glad to help you!:)

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.