gpt4 book ai didi

javascript - 如何在网格中使用 ng-repeat

转载 作者:行者123 更新时间:2023-12-03 09:10:40 24 4
gpt4 key购买 nike

我正在尝试将数组显示为每行两列,使用 Angular Directive(指令)这可能吗?或者我是否必须在 Controller 中编写一些逻辑。

Controller :

//don't know if i have to put some logic here

型号:

$scope.fruits = ['apple', 'banana', 'grapes', 'lemon']

查看:

<div class="row" ng-repeat="fruit in fruits">
<div class="col">{{fruits}}</div>
</div>

我正在使用 ionic 框架

最佳答案

根据您提供的代码中的类名,我假设您正在使用 Bootstrap。如果您想要每行 2 列,只需使用 col-md-6 将每列宽度设置为 50%:

<div class="row" ng-repeat="fruit in fruits">
<div class="col-md-6">{{fruit}}</div>
</div>

关于javascript - 如何在网格中使用 ng-repeat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32079048/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com