-1

I have a modification of the phonecat app from an AngularJS tutorial. However, depending on which lines I comment out, it either displays THs with images or doesn't populate that area of my page.

My code, among other permutations, is:

        <table border="0" id="book-list">
            <tbody>
                <tr ng-repeat="book in books | filter:query">
                    <th>
                        <a ng-href = "{{ book.url }} "><img ng-src="{{ book.cover }}"></a>
                    </th>
                    <td>
                        <!--
                        <p>{{ book.links }}</p>
                        <p>{{ book.snippet }}</p>
                        -->
                        <p ng-src="{{ book.links }}"></p>
                        <p ng-src="{{ book.snippet }}"></p>

                    </td>
            </tbody>
       </table>

The {{ book.links }} in particular escapes HTML, and I would like to pass the raw, unescaped HTML string (which I am the sole author for), instead of an escaped HTML string.

(I'm intentionally leaving out further details in the interest of preventing spam. If someone asks for a relevant XYZ, I should be able to post it.)

Christos Hayward
  • 5,777
  • 17
  • 58
  • 113

1 Answers1

2

Try using ng-bind-html="book.links"

It sanitizes the ressource first so it can be truly trusted

More details here https://docs.angularjs.org/api/ng/directive/ngBindHtml

Sami Triki
  • 408
  • 3
  • 7