[英]Angularjs attribute with html content
我想在属性中使用html内容来设置输出的样式,包括列表和强词等。
angular.module('calc.popover', []) .directive('popover', function() { return { restrict: 'E', templateUrl: '/partials/popover.tpl.html', scope: { title: '@', content: '@' } } };
<popover title="I am a popover" content="Many Text <br> New line. <ul><li> a list </li></ul>"></popover>
我怎样才能做到这一点? 如果我这样做,输出将显示html标记。
您需要使用'ngTransclude'属性来获取指令中的html模板内容,并将内容传递给指令,如下所示: <popover title="I am a popover"><br> New line. <ul><li> a list </li></ul>"></popover>
<popover title="I am a popover"><br> New line. <ul><li> a list </li></ul>"></popover>
对于工作示例,请检查: http : //plnkr.co/edit/5RKBZRBmEH6PMvmbZomt?p=preview
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.