javascripthtmlangularjsjavascript-marked

Rendering in MarkedJS


I have this problem where it dosent render my code properly for some odd reason, and ill show you my code. So here is my code from the Controller(AngularJS) :

$scope.$watch('creatorValue', function(current, original) {
          var htmlVal = document.getElementById('creatorValue').innerHTML;
          console.log(original);
           htmlVal = marked(original);
});

And here is a Minimal HTML:

<div class="topic-sentence">
        <p class="topic-text" id="creatorValue">{{creatorValue}}</p>
</div> 

Well as you can see i logged the original value and it came up with the correct result: enter image description here

Well yeah, it logs the correct thing.... Then It Must Show the right display right? enter image description here

Nope as you can see above, all the code is in one line, and there is nothing "marked". If you guys want to see more code, let me know in the comments below. Help would be very much appreciated.


Solution

  • Here, you have not put the marked content back to the DOM. This should work, please try.

    $scope.$watch('creatorValue', function(current, original) {          
        document.getElementById('creatorValue').innerHTML = marked(original);
    });