【问题标题】:Output HTML with Jade (within ng-repeat)使用 Jade 输出 HTML(在 ng-repeat 内)
【发布时间】:2016-05-03 12:09:55
【问题描述】:

我有一个应用程序控制器文件,它从数据库中获取有关过程的信息,其中一条信息是有关该过程的文档。

我面临的问题是,如果文档中有 HTML,JADE 将不会呈现它,它只是使用 html 实体!

现在我知道 !{VAR}p=!{VAR} 但是当我这样做时,我得到:

Cannot read property 'Doc' of undefined

获取信息的代码片段:

angular.module('app')
.controller('APIHelpCtrl', function ($scope, $location, $routeParams, $q, FormSvc, ApplicationSvc) {

    FormSvc.setOptions($scope)
    $scope.results = []

$scope.fetch=function(searchTerm) {
    $scope.results.length = 0
    searchTerm = searchTerm || '';
    return $scope.fetch({
        fetchAPI:'FETCHAPI='+searchTerm,
        multiRow:true,
        fetchTarget:'helpProcs',
        notLoggedIn:true
    })
}

$scope.pushResults=function(DescOnly){
    if (DescOnly == false) {
        $scope.results.push({name:buildObject.proccessName,Doc:buildObject.Doc,params:ar})
    }
}

JADE 文件中的片段(我无法弄清楚的部分)

div.results(ng-show="results.length > 0")
    h3 API Help
    .table-responsive
        table.table.table-striped
            thead
                tr
                    th Procedure
                    th.hideOnPrint  
            tbody
                tr(ng-repeat='proc in results')
                    td.printView 
                        p(ng-click='viewProcedure(proc.name)') {{ proc.name }}
                        p.helpDocumentation !{proc.Doc}

就像我之前提到的 !{proc.Doc} 导致无法读取属性错误 - 但如果我也更改它 {{proc.Doc}} 它可以很好地读取它(只是不呈现 HTML)

【问题讨论】:

    标签: javascript angularjs node.js pug


    【解决方案1】:

    解决了

    使用ng-bind-html 并清理了html

    【讨论】:

      猜你喜欢
      • 2018-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多