【发布时间】:2016-12-09 23:45:01
【问题描述】:
我正在使用文本编辑器TinyMCE,并且在从数据库中检索数据时,我试图将code 与一般描述区分开来。它旨在类似于 StackOverflows 编辑器。但是,我可以使用 ng-bind-html 转换 all html 标签,这是主要问题。我不想转换 code 部分。
例如:
<strong>hello</strong>
<code>
<div>i dont want the tags inside code to be converted</div>
<p>i am para</p>
</code>
想要的输出是:
你好
<code>
<div>i dont want the tags inside code to be converted</div>
<p>i am para</p>
</code>
但是,我使用 ng-bind-html 得到的输出是:
" 你好
我不希望代码中的标签被转换
我是帕拉。”
我正在使用angular 1.52 和laravel php。
我的部分:
<div ng-bind-html="myResult">
</div>
后端控制器:
public function getquesdet(){
$id = Request::input('id');
$data= Data::where('id','=',$id)->first();
$body = html_entity_decode($data['body']);
return html_entity_decode($body);
}
我的 angularjs 控制器:
app.controller('seperatequestion',['$scope','$rootScope','$http','$stateParams',function($scope,$rootScope,$http,$stateParams){
$http({
method:'GET',
url : $rootScope.apiend + '/getquestiondet',
params:{
id:$stateParams.qid
}
}).success(function(result){
$scope.myResult= result;
}).error(function(data){
console.log(data);
})
}])
所以,我想要的只是转换html标签,不包括code标签内的标签。
【问题讨论】:
标签: html angularjs laravel tinymce ng-bind-html