Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Angular 16, if the current date and time are not being preselected when opening the DateTime Picker #400

Open
kar7189 opened this issue Sep 19, 2024 · 1 comment

Comments

@kar7189
Copy link

kar7189 commented Sep 19, 2024

In Angular 16, if the current date and time are not being preselected when opening the DateTime Picker

@abhisheksinghrana
Copy link

Hi @kar7189 ,

Its duplicate thread of #356

Anyway added solution here as well.

I am using Angular 17.

In polyfills.ts file, Add the below mentioned code.

import { NgxMatTimepickerComponent } from '@angular-material-components/datetime-picker';

NgxMatTimepickerComponent.prototype.writeValue = function (val: any): void {
    if (val != null) {
        this._model = val;
    } else {
        this._model = this._dateAdapter.today();
        if (this.defaultTime != null) {
            this._dateAdapter.setTimeByDefaultValues(this._model, this.defaultTime);
        }
    }
    this._updateHourMinuteSecond();
    setTimeout(() => {
        this.form.updateValueAndValidity();
    });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants