ng-include 在 ng-table 中不起作用
ng-include in ng-table doesn't work
在我的table中,我有
<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
放在同一个视图中,那么它就可以工作。
不完全清楚发生了什么,但 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
子级的父级范围
在我的table中,我有
<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
放在同一个视图中,那么它就可以工作。
不完全清楚发生了什么,但 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
子级的父级范围