我的主计长:
LandingApp.controller('LandingCtrl2', function($scope){
$scope.articles = [
{
'imageSrc' : IMG_DIR + 'spec9.jpg',
'title' : 'Stencils',
'description': 'Plastic or thin metal stencils.<br/>100% Custom made'
}
];
});当我尝试我的ng重复(文章中的...article){article.description}时,我得到了... stencils.<br/>100% ....,但是我需要断线或其他一些html标记。我怎么才能解决这个问题?
发布于 2015-03-24 11:55:05
您需要创建一个方法,该方法可以告诉AngularJS将该字符串呈现为HTML
例子:
$scope.renderHtml = function (htmlCode) {
return $sce.trustAsHtml(htmlCode);
}在你的view里
<div ng-bind-html="renderHtml(article.description)"></div>不要忘记在控制器中包括$sce
LandingApp.controller('LandingCtrl2', function($scope,$sce){ ...https://stackoverflow.com/questions/29231979
复制相似问题