how to append items to the same row or line with ng-repeat

旧城冷巷雨未停 提交于 2019-12-22 05:55:25

问题


I'd like to append items to the same row with ng-repeat, but it seems to add the items on a new line. In the following example I'd like them to be on the same row like:

"John who is 25 years old. Jessie who is 30 years old. Johanna who is 28 years old."

The result is instead:

John who is 25 years old.
Jessie who is 30 years old.
Johanna who is 28 years old.

How can I accomplish that?

<div ng-init="friends = [
  {name:'John', age:25, gender:'boy'},
  {name:'Jessie', age:30, gender:'girl'},
  {name:'Johanna', age:28, gender:'girl'}
]">


<div ng-repeat="friend in friends">
    {{friend.name}} who is {{friend.age}} years old.
</div>

Stone


回答1:


Try this

<div ng-repeat="friend in friends" style="float:left">
   {{friend.name}} who is {{friend.age}} years old.
</div>

OR

<span ng-repeat="friend in friends">
    {{friend.name}} who is {{friend.age}} years old.
</span>

By default DIV render as display:block and SPAN as display:inline



来源:https://stackoverflow.com/questions/18349943/how-to-append-items-to-the-same-row-or-line-with-ng-repeat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!