started working not too long ago with angularJS so I still have some stuff I don't get.
Gonna try to be as simple as possible in the explanation, I'm working on small part of a bigger project, to get me going with angularJs, and I'm stuck on this.
Is there a good way to do the following in the frontend without touching API/Database?
I have an interface that returns me some data from the backend, When a user creates a new entry in the app, it registers the userID, activityID, the start date of the activity and the end date. So what I get is an array with some params like ID, startDate and endDate,
activities [
{id: 1, activityID: 5, startDate:1515628800000, endDate: 1515628800000},
{id: 2, activityID: 4, startDate:1515628800000, endDate: 1515628800000}
{id: 3, activityID: 8, startDate:1515628800000, endDate: 1515628800000},
{id: 4, activityID: 2, startDate:1515628800000, endDate: 1515628800000},]
(start dates and end dates are the same just for example)
I just need some help with the logic, if I can access this interface, and I have a function that takes as arguments 2 dates, one starting date and one ending date, and returns me the above array, with all the activities filtered by the range I put in the function, how can I order these data by weeks?
What I mean is, if I do a
<div class="tableRow" ng-repeat="t in vm.activitiesData.activities">
(activitiesData.activities
this is the already filtered interface, with only entries for january in this case),
Currently this returns me X Divs depending on how many activities there are.
What I want to achieve, is to return somehow for the filtered activities in January, 5 DIVS representing each week in january, and inside those divs, the data divided by week.
So I would need to come up with an ng-repeat that creates a DIV for a week, if there is data in that week.
If my actual result with the ng-repeat above is:
Activity 1
Activity 2
Activity 3
Activity 4
I want to get
Week 1
Activity 3
Week 2
Activity 4
Activity 1
Week 4
Activity 2
is this possible without touching the backend? As I said before, all that I can get now is an array of activities within a specific month, but need to figure out how to sort them in weeks while I use a ng-repeat to generate the data in the view.
Hope it s clear what Im trying to do, sorry for the confusion, thank you
edit: divs structure for my table:
<div class="activityTable" ng-repeat="t in vm.activitiesData.activities">
<div class="activityHeaderContent"> Week 01 </div>
<!-- this is the header with the week number, now all the data for that week should be put in the next div -->
<div class="activityRowContent" ng-repeat="nested ng repeat goes here"> Activity 1 </div>
</div>
so the result I want, is if we keep the previous example, where it generates 3 weeks and puts the activity in the respective week, to show 3 different DIVs, with the titles Week 1, Week 2, Week 4, and group those activities based on their start/end date in the correct Week