Is there a way to categorize information using an Angular ng-repeat?

I currently have a selection of objects on display along with their corresponding information. I am using ng-repeat to showcase all the objects, and now I am interested in implementing a filter or function to group the objects by month. If there are multiple objects registered in the same month, I would like to display all those objects together under that specific month

Below is my JSON Array, where the value "upload_date" indicates the month I want to extract

"_embedded": {
    "incidents": [
        {
            "id": 20,
            "name": "Incident Name",
            "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"
                }
            }

Here is my HTML code utilizing ng-repeat, which is functioning correctly

<ul class="list" >
               <h1>January</h1><br />**<---- HERE I WOULD LIKE TO SHOW THE MONTH**
               <br />
                <li class="list__item" ng-repeat="incident in incidents">
                    <a href="#" data-toggle="modal" data-target="#incidentModal" ng-click="selectIncident($index)">
                        <figure class="list__item__inner">
                            <div class="badges">
                                <span class="glyphicon glyphicon glyphicon-comment"><span> {{incident._embedded.commentsCount}} </span>
                                <span class="glyphicon glyphicon glyphicon-picture"><span> {{incident._embedded.attachmentsCount}} </span>
                            </div>
                            <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>
                                <p>{{incident.description | strLimit: 90 }}</p>
                                <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>
                                <p> <span class="glyphicon glyphicon-user"></span> {{incident._embedded.employee}}</p>
                            </figcaption>
                        </figure>
                    </a>
                </li>
            </ul>

My goal is to arrange all recorded objects neatly categorized by month. If there are no objects within a particular month, that month should not be displayed. However, I am uncertain about how to effectively group the objects by month

Answer №2

If you're seeking a way to automatically divide lists, check out this helpful example provided:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Replace existing material and add fresh content

Whenever the user clicks on an albumPreview element, a specific event is triggered. The functionality works smoothly when clicking on each albumPreview once. However, if clicked again, it only removes the content and does not append it again. The replaceW ...

What strategies can I implement to streamline my CSS code and avoid repeating the same styles multiple times within my HTML document?

The input box contains predefined values with unique IDs or generates them based on certain rules. Here is the HTML code: <input class="box" type="text" style="width:8%; text-align:center" id="a" value="A" readonly="true"/> <input class="box" ty ...

Enhancing Error Validation Messages in FormControl to Include More Specific Details

In continuation of my previous inquiry, my objective is to display a customized error message for user inputs. Instead of presenting users with a generic error message, I want to provide them with specific feedback. For example, if the input field only al ...

An issue is arising in NodeJS & MongoDB findAndModify where the wrong object is being updated

Encountering an issue with the findAndModify method - attempting to update a single record, but it always ends up updating the first record in the database. AngularJS call: $http.put('/fidlist/'+$scope.fid._id, $scope.fid) .then( function(respo ...

Ways to retrieve the file name from the content-disposition header

I received a file through an AJAX response. I am trying to extract the filename and file type from the content-disposition header in order to display a thumbnail for it. Despite conducting multiple searches, I have been unable to find a solution. $(". ...

Unexpected behavior in Node.js streams: callback in pipeline not being triggered

What could be causing the pipeline to never call its callback function? Additionally, why does the transform function stop being called after processing 16 chunks? For example: const { Readable, Transform, pipeline } = require('stream'); cons ...

Setting the base URL in Next.js according to an environment variable: a step-by-step guide

I currently have a Strapi backend and Next.js frontend application deployed on DigitalOcean. Within DigitalOcean, I have configured an environment variable for the frontend: API_URL = ${APP_URL}/api To generate the base URL, I retrieve this variable using ...

The proper method for updating data on a backend API using Axios and Vue

I am working on a Vue application that includes several form fields. I want to ensure that any changes made by the user are saved in real-time to a backend database using a REST API with Axios, without requiring the user to click a save button. I have two ...

What method can be used to segment data in an array while also factoring in the preceding value?

I currently have an array named targetPercentage. targetPercentage = [0,33,77,132] Is there a way to divide it into chunks of size 2 while also including the previous value? Additionally, is it possible to convert it into a JavaScript object array with c ...

Receiving an error when Node.JS spawns a Python process: `JSONDecodeError("Expecting value", s, err.value) from None`

I am attempting to launch a Python process (App.py) from a node.js file (index.js). In the script index.js, the python script App.py is spawned and passed an argument params in the form of a JSON object. App.py then extracts the value from the uParams ele ...

Opera does not support Ajax functionality

My ajax script is not functioning properly in Opera browser, although it works fine on other major browsers. $(function() { $("a").on('click', function(e) { var href = $(this).attr('href'); $.ajaxSetup({ beforeSend:fu ...

What is the best way to incorporate an environmental variable in my AngularJS controller?

My API Key is securely stored in my '.env' file to keep it hidden from Git. Here's a snippet of my .env file: API_TOKEN=secrettokengibberish When working on my Angular controller, I need to retrieve this variable for my AJAX call. This i ...

What is the recommended approach for utilizing props versus global state within your components when working with JS Frameworks such as Vue?

Currently, I am delving into a larger project using Vue and I find myself contemplating the best practices when it comes to utilizing props versus global Vuex states for accessing data within a component. To elaborate, let's say I have a component re ...

Tips for patiently waiting for a promise to be fulfilled

Currently, I am faced with a scenario in a NodeJs framework where a specific function must be synchronous, yet I need to access a value asynchronously. Ideally, I would be able to return a promise, however, that is not feasible. To address this issue quic ...

Achieving cell merging in react-table can be accomplished by utilizing the appropriate

Currently, I am using react-table and have the need to combine cells in specific columns based on their content. Essentially, I want to remove the divider border between these merged cells. To give you a visual idea, this is how it currently looks like: h ...

Creating a stylish look by incorporating bullet points into an active tab while also addressing challenges with vertical alignment and ensuring that the content remains contained within

Currently, I am in the process of enhancing an active tab on my menu by adding a bulletpoint. The script that accomplishes this is depicted below: $(document).ready(function() { //add class active to a tab based on url switch (window.location.p ...

Encountering a 401 Error while trying to host an Angular app on Google Cloud Storage

I am currently facing an issue with deploying my Angular app to a Google Cloud Storage bucket. The bucket is public and set up to be served as a custom website via CNAME (test.example.com). The main page and 404 handler are mapped to index.html, but I am e ...

Acquire the nested object within a MongoDB document using its assigned ID

Looking to retrieve and edit a specific comment within a post, but not sure where to start. Here is an example of my Post data structure: { "title" : "First Node.js App", "body" : "testing 123", "st ...

Troubleshooting Jquery Ajax Failure in Laravel 4

Whenever I utilize jQuery Ajax to insert data into the database, a peculiar issue arises. Upon clicking the submit button, my page mysteriously returns blank. To shed light on this dilemma, I decided to employ Firebug for debugging purposes, only to stumbl ...

What steps should I take if the slackbot is properly functioning after being invited to the channel?

Using an OAuth2 token I am looking to automate the process of sending data from Google Sheets via Slackbot. Even though I have set up tokens and connections, I find that I still need to manually input the channel id into my script. In order to streamline ...