0

I am using ionic tinder cards and each new card should be inserted in an predefined array as an object, likewise:

{text: "some_text"}

However, I might be getting html in the string and I want that html to be rendered. How can I do this considering the object above goes to a predefined array, something happens on the ionic code and then I inject it like this?

<div class="card">
        {{card.text}}
</div>

2 Answers 2

1

use ng-bind-html directive: may be require import the sanitize module

  <div class="card">
      <span  ng-bind-html="card.text"></span>      
  </div>
Sign up to request clarification or add additional context in comments.

3 Comments

And should this work with the default ionic tinder cards code? How should I implement the sanitize in this perspective?
inject sanitize in your app
and in this specific perspective? I'm not that familiar with angular
0

You should use ng-bind-html

<div class="card">
    <span ng-bind-html="card.text"></span>      
</div>

If your HTMl contains potentially dangeorus tag (like script tag), you should sanitize it before

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.