Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ng bind html中的Angularjs样式/突出显示代码块_Angularjs_Wordpress_Ng Bind Html - Fatal编程技术网

ng bind html中的Angularjs样式/突出显示代码块

ng bind html中的Angularjs样式/突出显示代码块,angularjs,wordpress,ng-bind-html,Angularjs,Wordpress,Ng Bind Html,为了学习Angualr.js,我尝试收集一篇Wordpress帖子,使用插件WP REST API,并以正确的格式显示在模板上。我已经得到了使用sanitize和ng bind html显示正确方式的帖子 但是,在文章中有一些代码块是我最初强调的(使用WP code Prettify)。例如: 问题是如何使用ng bind html使原始帖子看起来像上面的图片?还是有其他更有效的方法 您应该尝试使用$sce将帖子内容标记为可信 例如: .controller('CtrlName',

为了学习Angualr.js,我尝试收集一篇Wordpress帖子,使用插件WP REST API,并以正确的格式显示在模板上。我已经得到了使用sanitize和ng bind html显示正确方式的帖子

但是,在文章中有一些代码块是我最初强调的(使用WP code Prettify)。例如:


问题是如何使用ng bind html使原始帖子看起来像上面的图片?还是有其他更有效的方法

您应该尝试使用$sce将帖子内容标记为可信

例如:

    .controller('CtrlName', function($scope, $http, $sce) {
    $http.get('wp-json/pages/pageSlug').success(function(res){
        $scope.page = res;
        $scope.page.content = $sce.trustAsHtml(res.content);
    });
})

它已经应该-样式是内联的,或者如果您使用的是外部样式表,请检查为什么不应用它。除了一个问题外,它们显示正确。pre标记中的标记周围有双引号?这会阻止WP代码美化设置标记的样式。是否检查绑定中的数据本身是否包含引号?对于上面的示例,我返回的部分数据如下:\r\n// 车把模板\r\nscript id=";位置模板";类型=";正文/;x-把手-模板和#34/脚本\r\n我认为其中没有引号