Skip to content

Use LOCALE_ID as default for locale settings #5393

Closed
@csvn

Description

@csvn

Bug, feature request, or proposal:

Feature request

What is the expected behavior?

Use LOCALE_ID from @angular/core as default for NativeDateAdapter and possible other locale related features.

What is the current behavior?

NativeDateAdapter uses the browsers locale.

What are the steps to reproduce?

Providing a Plunker (or similar) is the best way to get the team to see your issue.
http://plnkr.co/edit/I5RmX52yjb4U1v8n0fYT?p=preview

What is the use-case or motivation for changing an existing behavior?

Currently, it feels very clunky that you have to manually set the locale that is used by the datepicker by setting locale on DateAdapter. Especially if LOCALE_ID has already been specified. I expected an Angular library like Material to use the same locale setting as Angular (LOCALE_ID).

import { LOCALE_ID } from '@angular/core';
import { DateAdapter } from '@angular/material';

@NgModule({
  providers: [
    provide: LOCALE_ID,
    useValue: 'sv-SE'
  }
})
export class AppModule {
  constructor(dateAdapter: DateAdapter) {
    dateAdapter.setLocale('sv-SE');
  }
}

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular: 4.2+
Angular Material: 2.0.0-beta.7

Is there anything else we should know?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions