0

I'm using Angular Bootstrap tabs. I'd like to use them with their content loaded from an Angular Model. However, all HTML in the content loaded fromt eh model is ignored. i.e. if I have

  $scope.tabs = [
    { title:'Dynamic Title 1', content:"<b>Dynamic</b> content 1" },
    { title:'Dynamic Title 2', content:'Dynamic content 2', disabled: true }
  ];

The first tab's content is "Dynamic content 1", not "Dynamic content 1" with "Dynamic" in bold. If the content as statically supplied in the html file, it would show correctly.

Plunker to demonstrate the problem

Anyone know how I can force the html to be parsed properly?

Thank you, Greg

2

1 Answer 1

1

Based in the comments, you can create a function called:

scope.trustHtml = function(content){
    return $sce.trustAsHtml( content );
}

and then change your HTML to be like:

<tab ng-repeat="tab in tabs" heading="{{tab.title}}" active="tab.active" disabled="tab.disabled">
    <span ng-bind-html="trustHtml(tab.content)"></span>
</tab>
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, that works. I tried something based on the comments, and it failed so completely I threw it away, and now have no idea what I did differently. :-) Oh, well, thank you for something that works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.