Angularjs NG-重复计数器 [英] Angularjs ng-repeat counter
本文介绍了Angularjs NG-重复计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用angularjs。我有一个NG重复显示的问题。我需要把出与1开始,持续到的问题,到底问题编号。如何显示和增加这样一个计数器NG-重复?
< UL>
<李NG重复=,在问题的问题|过滤器:{questionTypesId:questionType,选择:真正}>
< DIV>
<跨度类=名>
{{question.questionText}}
< / SPAN>
< / DIV>
< UL>
<李NG重复=答案question.answers>
<跨度类=名>
{{answer.selector}}。 {{answer.answerText}}
< / SPAN>
< /李>
< / UL>
< /李>
< / UL>
解决方案
Angularjs文档充满例子,你只需要花费一些时间,并探索它。
在这里看到这个例子: ngRepeat例如,这是相同的情况下,
\r
\r\r
\r < UL>\r
<李NG重复=,在问题的问题|过滤器:{questionTypesId:questionType,选择:真正}>\r
< DIV>\r
<跨度类=名>\r
{{$指数+ 1}} {{question.questionText}}\r
< / SPAN>\r
< / DIV>\r
< UL>\r
<李NG重复=答案question.answers>\r
<跨度类=名>\r
{{answer.selector}}。 {{answer.answerText}}\r
< / SPAN>\r
< /李>\r
< / UL>\r
< /李>\r
< / UL>
\r
I am using angularjs. I have a ng-repeat that displays questions. I need to out put a question number that starts with 1 and continues till the end of the questions. How do I display and increment such a counter in the ng-repeat?
<ul>
<li ng-repeat="question in questions | filter: {questionTypesId: questionType, selected: true}">
<div>
<span class="name">
{{ question.questionText }}
</span>
</div>
<ul>
<li ng-repeat="answer in question.answers">
<span class="name">
{{answer.selector}}. {{ answer.answerText }}
</span>
</li>
</ul>
</li>
</ul>
解决方案
Angularjs documentation is full of examples, you just need to take some time and explore it.
See this example here : ngRepeat example , it's the same case.
<ul>
<li ng-repeat="question in questions | filter: {questionTypesId: questionType, selected: true}">
<div>
<span class="name">
{{$index + 1}} {{ question.questionText }}
</span>
</div>
<ul>
<li ng-repeat="answer in question.answers">
<span class="name">
{{answer.selector}}. {{ answer.answerText }}
</span>
</li>
</ul>
</li>
</ul>
这篇关于Angularjs NG-重复计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文