I have a set of objects on display with the information about that object. I use ng-repeat to show all the objects, but I would now like to implement a filter or function, group objects by month, if i have objects registered in the same month, to show in my index all of the objects with that month
我有一组显示的对象,其中包含有关该对象的信息。我使用ng-repeat来显示所有对象,但我现在想要实现一个过滤器或函数,按月分组对象,如果我有同月注册的对象,则在我的索引中显示该月的所有对象
this is my JSON Array, with the value " upload_date " is where I would like to get the specific month
这是我的JSON数组,值“upload_date”是我想获得特定月份的地方
"_embedded": {
"incidents": [
{
"id": 20,
"name": "Nombre de incidente",
"description": "Lorem Ipsum is simply dummy text of the printing and typesetting industry.",
"timestamp": "2015-03-13T00:00:00-0600",
"upload_date": "2015-03-31T23:58:19-0600",
"archived": false,
"_links": {
"self": {
"href": "http://incidents-core/app_dev.php/incidents/20"
},
"attachments": {
"href": "http://incidents-core/app_dev.php/incidents/20/attachments"
},
"comments": {
"href": "http://incidents-core/app_dev.php/incidents/20/comments"
}
}
and here is my html code with ng-repeat, this works
这是我的HTML代码与ng-repeat,这是有效的
<ul class="list" >
<h1>January</h1><br />**<---- HERE I WOULD LIKE THO SHOW THE MONTH**
<br />
<li class="list__item" ng-repeat="incident in incidents">
<!-- ngrepeat: mostrar total de incidentes-->
<a href="#" data-toggle="modal" data-target="#incidentModal" ng-click="selectIncident($index)">
<!-- /.badgetSection-->
<figure class="list__item__inner">
<div class="bagdets">
<span class="glyphicon glyphicon glyphicon-comment"><span> {{incident._embedded.commentsCount}} </span>
<span class="glyphicon glyphicon glyphicon-picture"><span> {{incident._embedded.attachmentsCount}} </span>
</div>
<!-- ./badges -->
<div class="incident-image">
<img ng-src="{{incident._links.thumbnail.href || 'img/03.jpg'}}">
<p class="incident-type"><span>{{incident._embedded.incident_type}}</span>
</p>
</div>
<figcaption>
<p>{{incident.name}}</p>
<div class="line-separator"></div>
<p>{{incident.description | strLimit: 90 }}</p>
<div class="line-separator"></div>
<p><span class="glyphicon glyphicon-calendar"></span> {{incident.timestamp | date:'EEE - dd/mm/yyyy'}} <span class="glyphicon glyphicon-time"></span> {{incident.timestamp | date:'hh:mm:ss a'}}</p>
<div class="line-separator"></div>
<p> <span class="glyphicon glyphicon-user"></span> {{incident._embedded.employee}}</p>
</figcaption>
</figure>
</a>
</li>
</ul>
My idea is to try and show all registered objects sorted by month , if there are no objects in that month , just do not show the month. But I don't know how can I grouping by months
我的想法是尝试显示按月排序的所有已注册对象,如果该月没有对象,则不显示月份。但我不知道我怎么能按月分组
2 个解决方案
#1
check this angular-filter which provides so many options https://github.com/a8m/angular-filter
检查这个角度过滤器,它提供了很多选项https://github.com/a8m/angular-filter
#2
What your are looking for is to perform an automatic list divider.
您正在寻找的是执行自动列表分隔符。
See that nice exemple for more information : http://mcgivery.com/dividing-list-automatically-ionic-framework/
有关详细信息,请参阅该示例:http://mcgivery.com/dividing-list-automatically-ionic-framework/
#1
check this angular-filter which provides so many options https://github.com/a8m/angular-filter
检查这个角度过滤器,它提供了很多选项https://github.com/a8m/angular-filter
#2
What your are looking for is to perform an automatic list divider.
您正在寻找的是执行自动列表分隔符。
See that nice exemple for more information : http://mcgivery.com/dividing-list-automatically-ionic-framework/
有关详细信息,请参阅该示例:http://mcgivery.com/dividing-list-automatically-ionic-framework/