在我的表格中,我有
<tr
ng-repeat="question in $data"
ng-include="'/views/partials/questionList.html'"></tr>
在questionList.html
,我有:
<td class="top-td" data-title="'ID'" sortable="'id'">
<a href="#" ng-click="loadQuestionModal(question.id)">
{{ question.id }}
</a>
</td>
<td class="top-td" data-title="'Question / Instruction'">
<h6 markdown-to-html="question.Instruction.instructionText"></h6>
<blockquote ng-show="k8englishSubject" markdown-to-html="question.questionText"></blockquote>
<blockquote markdown-to-html="question.questionText" mathjax-bind="question.questionText" ng-show="k8mathSubject"></blockquote>
</td>
<td class="top-td"><ng-include src="'/views/partials/answerList.html'"></ng-include></td>
<td class="top-td" ng-show="k8englishSubject">
<a ui-sref="passages.upsert({passageId: question.PassageId})" ng-show="question.PassageId">
{{ question.Passage.passageTitle }}
</a>
</td>
<td class="top-td" data-title="'Level'" sortable="'level'">{{ question.level }}</td>
然而,这并没有呈现任何标题。但是,如果我有一个常规tr
并将td
放在同一视图中,那么它就能正常工作。
答案 0 :(得分:1)
不完全清楚发生了什么,但ng-repeat
和ng-include
都创建了子范围。
我建议你用自己的指令替换ng-include
以避免额外的子范围
<tr ng-repeat="question in $data" my-directive></tr>
JS
app.directive('myDirective',function(){
return {
restrict:'A',
templateUrl:'/views/partials/questionList.html';
};
});
目前,该指令的唯一功能是提供模板,并且它将在每次迭代中继承ng-repeat
子的父范围