I'm facing a challenge with databinding when working with nested arrays in multiple timeslots and windows. Despite understanding the basics, I can't seem to make it work no matter how I try different approaches. It's really frustrating not knowing what exactly I'm missing.
export interface Timeslot {
from: Date;
to: Date;
sunday: boolean;
monday: boolean;
tuesday: boolean;
wednesday: boolean;
thursday: boolean;
friday: boolean;
saturday: boolean;
windows: Window[];
}
export interface Window {
from: any;
to: any;
maxAvailability: number;
isOpen: boolean;
}
timeslots: Timeslot[] = [
{
from: new Date("January 01, 1990 10:05:00"),
to: new Date("December 31, 2021 10:05:00"),
sunday: false,
monday: true,
tuesday: true,
wednesday: true,
thursday: true,
friday: true,
saturday: false,
windows: [
{
from: "8:00",
to: "12:00",
maxAvailability: 100,
isOpen: true
},
{
from: "12:00",
to: "4:00",
maxAvailability: 80,
isOpen: true
},
{
from: "4:00",
to: "9:00",
maxAvailability: 80,
isOpen: true
},
]
}
];
Why is it not possible to use something like {{ timeslot.windows.from }}
to display nested data? What would be the correct approach to achieve this instead?
Furthermore, how can I calculate and display the total number of windows
? For example, in this scenario, the answer should be 3. Is there a way to do this using {{ timeslot.windows.length }}
?