Open cms103 opened 8 years ago
I am new using to angular trix. I am having some trouble in retrieving the data from the database. As shown above when I save the content from the editor to database it is saving fine but when I retrieve instead of the data what I saved, HTML tags are applying.
For example: in the editor if save Sample content as bold and when I reload the page after saving it is displayed as < div >< strong>Sample content< /strong>< /div> but I just need Sample content in bold. Please help me in fixing this issue.
See this: https://github.com/basecamp/trix/issues/249 In other words you are supposed to use val() instead of html() in trix-change @sachinchoolur please fix
The library currently takes the HTML of the editor and binds it to the Angular variable. This results in some internal Trix HTML comments being added to the HTML (
<!--block-->
- see below). A better way is to use Trix to serialize the editor state into HTML:Replace:
ngModel.$setViewValue(element.html());
withngModel.$setViewValue(Trix.serializeToContentType(element[0], "text/html"))
The HTML output changes from this:
<div><!--block-->Test<br><br>Now works correctly!<br><br><strong>Bold</strong> and <em>great</em> once again.<br><br><strong><br></strong><br></div>
to the nicer:
<div>Test<br><br>Now works correctly!<br><br><strong>Bold</strong> and <em>great</em> once again.<br><br><strong><br></strong><br></div>