Giter VIP home page Giter VIP logo

Comments (9)

dhutaryan avatar dhutaryan commented on September 15, 2024 1

So, now you can use provideNativeDateTimeAdapter function as provider and override MAT_TIME_LOCALE for each component separately. Tested it on your stackblitz. It works.

Implemented in:
15.3.0
16.3.0
17.5.0

from ngx-mat-timepicker.

dhutaryan avatar dhutaryan commented on September 15, 2024

Did you try the approach below?

import { LOCALE_ID, NgModule } from '@angular/core';

@NgModule({
  imports: [
    // ...
  ],
  providers: [{ provide: LOCALE_ID, useValue: "en-GB" }],
})
export class MyModule {}

from ngx-mat-timepicker.

k3nsei avatar k3nsei commented on September 15, 2024

@dhutaryan yes zero effect still using en-US

image

image

from ngx-mat-timepicker.

dhutaryan avatar dhutaryan commented on September 15, 2024

No-no, override LOCALE_ID

from ngx-mat-timepicker.

k3nsei avatar k3nsei commented on September 15, 2024

That one would work, but I want to have possibility to control config just for time picker, because our modules differ in business logic requirements, so they need to be configurable based on provided config.

I'm thinking that proposed solution should fix the issue.

from ngx-mat-timepicker.

k3nsei avatar k3nsei commented on September 15, 2024

Actually even when I override LOCALE_ID it isn't working. Maybe it takes value from RootInjector and ignoring ComponentInjector value. So the only working option form me currently is to replace provider for TimeAdapter.

image

image

from ngx-mat-timepicker.

dhutaryan avatar dhutaryan commented on September 15, 2024

That one would work, but I want to have possibility to control config just for time picker, because our modules differ in business logic requirements, so they need to be configurable based on provided config.

Make sense. Anyway, this works for me:

import { LOCALE_ID, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { MatNativeDateTimeModule, MatTimepickerModule } from 'mat-timepicker';

@NgModule({
  declarations: [
  ],
  imports: [
    CommonModule,
    MatTimepickerModule,
    MatNativeDateTimeModule,
  ],
  providers: [
    {
      provide: LOCALE_ID,
      useValue: 'pl-PL',
    },
  ],
})
export class MyModule {}

from ngx-mat-timepicker.

k3nsei avatar k3nsei commented on September 15, 2024

@dhutaryan I figured out how to make it work, but it's kinda hacky. I just reporting bug.
Here is reproduction what exactly isn't working: https://stackblitz.com/edit/stackblitz-starters-pgbyuy?file=src%2Fmain.ts

Angular have hierarchical dependency injection tree. Currently only value from RootInjector is respected and used. Overriding value in other parts of hierarchy isn't respected. Usually for most projects it's doesn't matter, but there are also those big ones with complicated business logic, that are using those advanced patterns and features.

from ngx-mat-timepicker.

dhutaryan avatar dhutaryan commented on September 15, 2024

So, this is related to one feature that I wanted to implement. I'd like to make implementation closer to standalone API. It should help.

from ngx-mat-timepicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.