Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen77sk committed Mar 21, 2024
1 parent ad5c960 commit 659aa96
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,25 @@ Both `date-fns` and `date-fns-jalali` libraries are peer dependencies, but requi

## Usage

1. Register the **NgxMatDateFnsModule** in your app module.
1. Provider the **provideDateFnsAdapter** in your app.config.ts.

```typescript
import { NgxMatDateFnsModule } from 'ngx-material-date-fns-adapter';

@NgModule({
...
imports: [
...
NgxMatDateFnsModule,
],
...
})
export class AppModule { }
import { provideDateFnsAdapter } from 'ngx-material-date-fns-adapter';

export const appConfig: ApplicationConfig = {
providers: [..., provideDateFnsAdapter()],
};
```

2. Register custom locale token in providers if needed.

```typescript
import { MAT_DATE_LOCALE } from "@angular/material/core";
import { fr } from 'date-fns/esm/locale';
@NgModule({
...
providers: [{ provide: MAT_DATE_LOCALE, useValue: fr }]
...
})
export class AppModule { }
import { fr } from 'date-fns/locale';
export const appConfig: ApplicationConfig = {
providers: [..., { provide: MAT_DATE_LOCALE, useValue: fr }],
};
```

## Change locale dynamically
Expand All @@ -76,7 +67,7 @@ Use `setLocale()` method of the DateAdapter. In case of using setLocale with a *
```typescript
import { Component } from '@angular/core';
import { DateAdapter } from '@angular/material/core';
import { enUS, faIR } from 'date-fns/esm/locale';
import { enUS, faIR } from 'date-fns/locale';
@Component({
selector: 'app-root',
Expand Down

0 comments on commit 659aa96

Please sign in to comment.