My data consists of outputs from 2 different shifts: one from 8pm to 8am and the other from 20am to 7am. I have used ngx-pipes
to filter the output, but now I need to sort the Night Shift hours from 8pm to 7am in the morning.
I have an array that specifies the correct order of the hours.
shiftSelection = [
{
name: "Day Shift",
hours: [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
},
{
name: "Night Shift",
hours: [20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7]
}]
data = [
{
"lineId": 1,
"hour": 0,
"input": 9136,
"output": 8850
},
...
{
"lineId": 1,
"hour": 23,
"input": 9136,
"output": 8850,
}]
How can I arrange ngFor output based on another array?
<div *ngFor="let row of data | filterBy: ['hour']: currShift.hours :1 | groupBy: 'lineId' | pairs">
<span class="group-title">Line {{row[0]}}</span>
<ng-container *ngFor="let cell of row[1]">
<span class="cell" matTooltip="{{cell | json}}">{{cell.output}}
</span>
</ng-container>
</div>
Something like this would be perfect:
*ngFor="let cell of row[1] | orderBy: currShift"