Skip to content

Not working with dynamically pulled data #87

Description

@relentless-coder

Hi, I have been trying to make this work for a while now.

First of all, content is a blog post, and it is a mixed content. So there are a few p blocks, and then pre code blocks. I have manipulated the data and placed hljs directive to the code tag, but it isn't working for me.

    postSingleFactory.getPost($stateParams.url).then((data) => {
      ctrl.post = data.data.post;
      ctrl.post.comments.forEach(el => el.replyVisible = false);
      ctrl.post.content = ctrl.post.content.replace('<pre class="language-markup">', '<pre>');      
      ctrl.post.content = ctrl.post.content.replace('<code>', '<code hljs hljs-language="js">');
      console.log(ctrl.post.content);
    })
  
  ctrl.trustThis = (html)=>{
    return $sce.trustAsHtml(html);
  }

and here is how I am using it

    <div class="single_post_content" ng-bind-html="sm.trustThis(sm.post.content)">

As i can see by inspecting my page that the code block contains the two directives, but it isn't working. There are no errors, the css is loading properly too.

Why would this be happening?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions