admin管理员组文章数量:1391987
I have an ng-repeat <ul>
list.
I want to insert <br>
after each <ul>
tag.
How can i do this?.
Here is my code
<ul class="list" ng-repeat="result in results">
<li class="list__header">{{$index+1}}</li>
<li class="list__item">{{result.name}}</li>
<li class="list__item">{{result.address}}</li>
<li class="list__item">{{result.phone_number}}</li>
</ul><br><br>
The above <br>
is not renderd
I have an ng-repeat <ul>
list.
I want to insert <br>
after each <ul>
tag.
How can i do this?.
Here is my code
<ul class="list" ng-repeat="result in results">
<li class="list__header">{{$index+1}}</li>
<li class="list__item">{{result.name}}</li>
<li class="list__item">{{result.address}}</li>
<li class="list__item">{{result.phone_number}}</li>
</ul><br><br>
The above <br>
is not renderd
2 Answers
Reset to default 8Use ng-repeat-start
and ng-repeat-end
:
<ul class="list" ng-repeat-start="result in results">
<li class="list__header">{{$index+1}}</li>
<li class="list__item">{{result.name}}</li>
<li class="list__item">{{result.address}}</li>
<li class="list__item">{{result.phone_number}}</li>
</ul><br><br ng-repeat-end />
Documentation: https://docs.angularjs/api/ng/directive/ngRepeat#special-repeat-start-and-end-points
You can also use a custom directive for this purpose:
.directive("insertAfter", function(){
return {
scope: {
content: "@"
},
link: function(scope, element, attrs){
element.after(scope.content);
}
}
});
Then use it inside of your list:
<ul class="list" ng-repeat="result in photos" insert-after content="<br>">...</ul>
本文标签: javascriptltbrgt tag in ngrepeat angularjsStack Overflow
版权声明:本文标题:javascript - <br> tag in ng-repeat angular-js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744764882a2623978.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论