Reputation: 299
I want to select entire week(only working days mon-fri) once I click on a date. I'm using Angular Material 7.3.6 and for the datepicker I'm using "NgbDatepicker" from here
First I tried to get the week number relavente to the selected date, from "getWeekNumber" as in the documentation. But it give this error: "ERROR TypeError: Cannot read property 'year' of undefined"
I'm new to the Angular, Angular Material. My aim is to select the entire week by using week number.
Upvotes: 2
Views: 1565
Reputation: 2175
You can use moment library which is great for date functions.
Solution:
let weeknumber = moment(selectedDateFromPicker).week();
console.log(weeknumber);
Upvotes: 2