Adam Silva Adam Silva - 1 month ago 7
AngularJS Question

Convert HTML from DB

I'm using TextAngular to save some posts to the database(with data type being

text
). It stores in the database like:
<h1>This is a header</h1>
. But when I go to retrieve from the database and display it in the HTML, it displays like
<h1>This is a header</h1>
.

Any idea how I can convert it either in the PHP or Javascript so it appears with the corresponding styles?

P.S.: I'm using Laravel for back-end(retrieval of data) and AngularJS for front-end(displaying data).

Answer

You don't need to convert anything. Just use ng-bind-html.

Take a look to the documentation for more information : https://docs.angularjs.org/api/ng/directive/ngBindHtml