1

要在模板中呈现带有连字符的属性名称的表达式,必须使用方括号而不是点。示例 docs["paragraph-content"] 而不是 docs.paragraph-content。我正在尝试在指令模板中的 ng-bind-html-unsafe 中打印此变量,例如 ng-bind-html-unsafe="doc["paragraph-content"]" 但出现语法错误,错误:语法错误: 标记“未定义”不是从 [doc[] 开始的表达式 [doc[] 的 NaN 列的主表达式。

      template: '<div>' +
            '<input ng-model="query" placeholder="Check your face" name="Search"></input>' +
            '<h2 id="search-list-title" class="list-header-title">Search Results for {{query}}</h2>' +
            '<form id="search-list-form" class="list-row list-form" ng-repeat="doc in results.docs">' +
            '  <a  id="search-item-title" class="list-element list-title" href="retrieve-graph?id={{doc.id}}"><p>{{doc["paragraph-subject"]}}</p></a>'  +
            ' <p id="search-item-content" class= "list-element list-content" ng-bind-html-unsafe="doc["paragraph-content"]"></p>'  +
            '  <p id="search-item-id" class= "list-email list-element">{{doc["user-email"]}}</p>'  +
            '  <!--<p>{{doc.title}}</p>-->'  +
            '  <!--urls point to user paragraph list and goes to specific paragraph through anchor link'  +
            ' <!--Need to create form that inserts id as parameter so can query and display on template page <p><a target="_blank" href="{{doc.id}}"> {{doc.url}}</a></p>-->' +
            ' <br>'+
            '</form>'+
            '</div>'
            ,
4

0 回答 0