This is my custom directive for reading more and to_trusted (for converting to 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);
};
}]);
call in 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>
If iI removes ng-bind-htmlthen reading more works fine, but the readmoreng-bind-html directive does not work.
source
share