I am trying to set the correct (locale based) start of the week for date picker. So i used this and that question and implemented my own DateAdapter:
import { NativeDateAdapter } from "@angular/material/core/datetime";
import { Injectable } from "@angular/core";
import { LOCALE_ID, Inject } from "@angular/core";
import { Platform } from "@angular/cdk/platform";
import { getLocaleFirstDayOfWeek } from "@angular/common";
@Injectable()
export class LocaleDateAdapter extends NativeDateAdapter {
constructor(@Inject(LOCALE_ID) public locale: string) {
super(locale, new Platform());
}
getFirstDayOfWeek() {
return getLocaleFirstDayOfWeek(this.locale);
}
}
i also put it into providers accordingly:
import { LocaleDateAdapter } from './components/shared-components/locale-date-adapter';
import { DateAdapter } from '@angular/material/core/datetime';
...
providers: [
...
{
provide: DateAdapter,
useClass: LocaleDateAdapter
}
...
While VS Code seems to be fine with it the compiler moans about:
ERROR in ./src/app/app.module.ts
Module not found: Error: Can't resolve '@angular/material/core/datetime' in '...\src\app'
ERROR in ./src/app/components/shared-components/locale-date-adapter.ts
Module not found: Error: Can't resolve '@angular/material/core/datetime' in '...\src\app\components\shared-components'
So how to make this work. (I also would be fine with less code to get the start of the week locale aware)