【发布时间】:2015-08-09 05:19:27
【问题描述】:
这些是我的自定义指令,用于阅读更多内容和 to_trusted(用于转换为 html)。
psp.directive('hmRead', function () {
return {
restrict:'AE',
scope:{
hmtext : '@',
hmlimit : '@',
hmfulltext:'@',
hmMoreText:'@',
hmLessText:'@',
hmMoreClass:'@',
hmLessClass:'@'
},
templateUrl: 'partials/common/read-more.html',
controller : function($scope){
$scope.toggleValue=function(){
if($scope.hmfulltext == true)
$scope.hmfulltext=false;
else if($scope.hmfulltext == false)
$scope.hmfulltext=true;
else
$scope.hmfulltext=true;
}
}
};
});
psp.filter('to_trusted', ['$sce', function($sce){
return function(text) {
return $sce.trustAsHtml(text);
};
}]);
在 html 中调用。
<hm-read hmtext="{{data.content}}" ng-bind-html="data.content| to_trusted" hmlimit="100" hm-more-text="read more" hm-less-text="read less"></hm-read>
如果我删除ng-bind-html 然后阅读更多工作正常但ng-bind-html 指令 readmore 指令不起作用。
【问题讨论】:
标签: javascript html angularjs