本文介绍了具有ng-repeat的数组的数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试显示按日期分组的列表,但该列表未排序,也不知道日期何时更改.就像我有这个Json一样:

I am trying to show a list grouped by date but the list isn't sorted and I don't know when the date change.It's like I have this Json :

list =
{name: first, date: 2014-05-21}, {
{name: second, date: 2014-05-20}, {
{name: third, date: 2014-05-21}

我想制作以下html:

I'd like to make the following html :

<li><h3>2014-05-21</h3>
 <ul>
  <li>first</li>
  <li>third</li>
 </ul>
</li>
<li><h3>2014-05-20</h3>
 <ul>
 <li>second</li>
 </ul>
</li>

你有个主意吗?

我试图像这样用两个ng-repeat制作一个数组数组:

I tried to make an Array of arrays with two ng-repeat like this :

for (i in list){
 if ($scope.listToShow[list.date] == undefined) {
     $scope.listToShow[list.date] = newArray();
 }
 $scope.listToShow[list.date].push(list[i]);
}

但我没有成功展示这一点.

But I don't success to show this.

推荐答案

检查发布,它恰好提到了您想要实现的目标.

Check the post, it exactly mention what you want to achieve.

http://www.bennadel. com/blog/2456-grouping-nested-ngrepeat-lists-in-angularjs.htm

http://www.bennadel.com/blog/2456-grouping-nested-ngrepeat-lists-in-angularjs.htm

OR

您也可以使用ng-repeat-start and ng-repeat-end(内置指令)来实现相同目的.单击此处以获取参考链接.

You can also use ng-repeat-start and ng-repeat-end (inbuilt directives) to achieve the same.Click here for Reference link.

这篇关于具有ng-repeat的数组的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 15:33