简体   繁体   English

标签动态内容的角度引导HTML处理

[英]Angular bootstrap HTML processing of tab dynamic content

I'm using Angular Bootstrap tabs. 我正在使用Angular Bootstrap选项卡。 I'd like to use them with their content loaded from an Angular Model. 我想将它们与从Angular模型加载的内容一起使用。 However, all HTML in the content loaded fromt eh model is ignored. 但是,将忽略从模型加载的内容中的所有HTML。 ie 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. 第一个标签的内容是“ 动态内容1”,而不是加粗的“动态”的“动态内容1”。 If the content as statically supplied in the html file, it would show correctly. 如果html文件中静态提供了内容,则它将正确显示。

Plunker to demonstrate the problem 演示问题

Anyone know how I can force the html to be parsed properly? 任何人都知道我如何可以强制正确地解析html?

Thank you, Greg 谢谢你,格雷格

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: 然后将您的HTML更改为:

<tab ng-repeat="tab in tabs" heading="{{tab.title}}" active="tab.active" disabled="tab.disabled">
    <span ng-bind-html="trustHtml(tab.content)"></span>
</tab>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM