admin管理员组文章数量:1356914
I want to insert new line like a following.
div.row
div.span12
div(ng-repeat="(data in datas)")
p data.text
// insert new line when $index is the number divisible by 3.
how does it do?
thank you.
I want to insert new line like a following.
div.row
div.span12
div(ng-repeat="(data in datas)")
p data.text
// insert new line when $index is the number divisible by 3.
how does it do?
thank you.
Share Improve this question asked Jul 21, 2013 at 3:56 tonpatonpa 211 gold badge1 silver badge2 bronze badges 1- Can you include some examples of what you have tried and show the desired output? – Ro Yo Mi Commented Jul 21, 2013 at 4:18
2 Answers
Reset to default 5You can use the ng-if directive, you would show a line break every time your $index matches a certain condition. So if you'd like to break after 3 iterations:
<div ng-repeat="data in datas">
{{ data }}
<br ng-if="($index+1)%3==0">
<div>
I am not sure what your end result will be, but there are a few ways that I would approach this. The first is to use ng-hide and ng-show to do something different on items that are divisible by 3. The other way would be to use ng-class to just style the 3rd element differently.
<div ng-repeat="data in datas">
<div ng-class="{'red': ($index+1)%3==0}">{{data}}</div>
<div>
Here is a jsFiddle
本文标签:
版权声明:本文标题:javascript - How to insert new line within ng-repeat of the middle (Angularjs + twitter bootstrap + jade) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744063473a2584556.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论