Giter Site home page Giter Site logo

iliaidakiev / angular-material-timepicker Goto Github PK

View Code? Open in Web Editor NEW
58.0 5.0 18.0 1.79 MB

Angular Material Timepicker Input for Template and Reactive forms

License: MIT License

JavaScript 3.92% TypeScript 71.81% HTML 17.32% SCSS 6.95%
angular material-design timepicker angular-material

angular-material-timepicker's Introduction

Angular Material Timepicker

Installation

  • npm install mat-timepicker || yarn add mat-timepicker

Features:

  • Clock view dialog for selecting hour and minutes and options for dialog toggle customizations.
  • Input time editing.
  • Validations: minDate / maxDate (options: strict - datetime check / non-strict - time check).
  • The timepicker can be used with template and reactive forms.

Configuration and usage

Keep in mind that the selector for the timepicker directive is input[matTimepicker]

your.module.ts

import { MatTimepickerModule } from 'mat-timepicker';

@NgModule({
  declarations: [...],
  imports: [
    MatTimepickerModule 
  ],
  ...
})
export class YourModule { }

Simple Case

<input matTimepicker>

More Complex Case

<mat-form-field appearance="fill">
  <mat-label>TIMEPICKER</mat-label>

  <!-- The timepicker input -->
  <input matTimepicker #t="matTimepicker" #time="ngModel" [minDate]="minValue" [maxDate]="maxValue"
    [strict]="false" id="timepicker-example" mode="24h" [ngModel]="defaultValue"
    placeholder="Please select time..." name="time" [errorStateMatcher]="customErrorStateMatcher" required
    (timeChange)="timeChangeHandler($event)" (invalidInput)="invalidInputHandler()">

  <!-- An icon for the timepicker input that will open the timepicker dialog when clicked -->
  <mat-icon matSuffix (click)="t.showDialog()">access_time</mat-icon>

  <!-- Error that will be shown when the input date is invalid -->
  <mat-error *ngIf="time.touched && time.invalid">Invalid Date</mat-error>
</mat-form-field>

MatTimepicker Directive API

@Input() required = false;
@Input() disabled = false;
@Input() placeholder = null;

/* Use a custom template for the ok button */
@Input() okButtonTemplate: TemplateRef<MatTimepickerButtonTemplateContext> | null = null;
/* Use a custom template for the cancel button */
@Input() cancelButtonTemplate: TemplateRef<MatTimepickerButtonTemplateContext> | null = null;
/* Where:
  export interface MatTimepickerButtonTemplateContext {
    $implicit: () => void; <--- The click handler for each the button (either okClickHandler/closeClickHandler)
    label: string; <--- The label that was provided to the mat-timepicker directive (either okLabel/cancelLabel)
  }
  In order to use this check out the bottom of the template driven form inside the example app
*/

/* Override the label of the ok button. */
@Input() okLabel = 'Ok';

/* Override the label of the cancel button. */
@Input() cancelLabel = 'Cancel';

/** Override the ante meridiem abbreviation. */
@Input() anteMeridiemAbbreviation = 'am';

/** Override the post meridiem abbreviation. */
@Input() postMeridiemAbbreviation = 'pm';

/* Sets the clock mode, 12-hour or 24-hour clocks are supported. */
@Input() mode: '12h' | '24h' = '24h';

/* Set the color of the timepicker control */
@Input() color: ThemePalette = 'primary';

/* Set the value of the timepicker control */
/* ⚠️(when using template driven forms then you should use [ngModel]="someValue")⚠️ */
@Input() value: Date = new Date(); 

/* Minimum time to pick from */
@Input() minDate: Date;

/* Maximum time to pick from */
@Input() maxDate: Date;

/* Disables the dialog open when clicking the input field */
@Input() disableDialogOpenOnClick = false;

/* Input that allows you to control when the control is in an errored state */
/* (check out the demo app) */
@Input() errorStateMatcher: ErrorStateMatcher;

/* Strict mode checks the full date (Day/Month/Year Hours:Minutes) when doing the minDate maxDate validation. If you need to check only the Hours:Minutes then you can set it to false */
@Input() strict = true;

/* Emits when time has changed */
@Output() timeChange: EventEmitter<any> = new EventEmitter<any>();

/* Emits when the input is invalid */
@Output() invalidInput: EventEmitter<any> = new EventEmitter<any>();

Check out the Demo App! (Please note that stackblitz sometimes fails to run Angular applications properly and that doesn't mean that the library is broken)


i18n (v5.0.0+)

In versions before v5.0.0 putting import '@angular/localize/init'; inside polyfills.ts was mandatory. From v5.0.0 it is no longer mandatory (which is useful for users that are not using i18n). In order to use i18n you have to use the inputs: okLabel, cancelLabel.

Please note that you need to provide both the input attribute and the value (e.g okLabel="Ok") and the i18n attribute (e.g i18n-okLabel="|@@") for more info check out this

Example:

<div>
  <mat-form-field appearance="fill">
    <mat-label i18n="Timepicker 1 Title">24 TIMEPICKER</mat-label>
    <input matTimepicker #t1="matTimepicker" i18n-okLabel="Timepicker 1 Ok Label" okLabel="Ok"
      i18n-cancelLabel="Timepicker 1 Cancel Label" cancelLabel="Cancel" #time1="ngModel" [minDate]="minValue"
      [maxDate]="maxValue" id="timepicker-example-1" mode="24h" ngModel placeholder="Please select time..."
      name="time-1" required>
    <mat-icon matSuffix (click)="t1.showDialog()">access_time</mat-icon>
    <mat-error *ngIf="time1.touched && time1.invalid">Invalid Date</mat-error>
  </mat-form-field>
</div>

Dialog View

Hour Select (24h):

alt text

Minutes Select:

alt text

angular-material-timepicker's People

Contributors

dan890 avatar dependabot[bot] avatar iliaidakiev avatar martin-havala avatar mdrgzi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

angular-material-timepicker's Issues

Angular 14 support

Hello, when upgrading to angular 14, some warnings are displayed
Package "mat-timepicker" has an incompatible peer dependency to "@angular/cdk" (requires "^11.2.12", would install "14.0.2").

Would it be possible to solve this ?

Make i18n optional

Hi, first of all great library 👍

I use in my projects ngx-translate for the internationalization and not i18n. Unfortunately this library is the only one that forces me to import @angular/localize. I was wondering, if it is possible to make the i18n support somehow optional so that we aren't forced to use i18n? I would really appreciate this.

Thanks and have a good day,
Marcel

custom theme problems?

if i provide a custom theme and none of the material default strage things happen to the picker:

grafik

how can i fix this?

Change semver range to not break on every new Angular release

Instead of using "@angular/cdk": "^14.1.1", you could use "@angular/cdk": ">=14", or even >=12, if 12 or whatever version supports everything this lib needs).

Yes, this might break with a new Angular version, but most likely it will just work fine and we can get rid of using --force on npm install.

How can I change the font of the dropdown menus when using type="time"?

I'd like to be able to change the font of the element below:
image

However, I can't for the life of me access this element in the Chrome dev tools. Whenever I interact with any element on the page, or in the tools, this input closes. I can't find which elements or classes I need to manipulate to change the font styling.

Angular 8 An accessor cannot be declare d in an ambient context.

I am working in a project that is in angular 8 and i want to use this component but in the console i have this error and in the view the component appearce but the interface is broken:

ERROR in node_modules/mat-timepicker/lib/timepicker-dialog/timepicker-dialog.component.d.ts(20,9): error TS1086: An accessor cannot be declare
d in an ambient context.
node_modules/mat-timepicker/lib/timepicker-dialog/timepicker-dialog.component.d.ts(21,9): error TS1086: An accessor cannot be declared in an a
mbient context.
node_modules/mat-timepicker/lib/timepicker-dialog/timepicker-dialog.component.d.ts(38,9): error TS1086: An accessor cannot be declared in an a
mbient context.
node_modules/mat-timepicker/lib/timepicker-dialog/timepicker-dialog.component.d.ts(39,9): error TS1086: An accessor cannot be declared in an a
mbient context.
node_modules/mat-timepicker/lib/timepicker-dialog/timepicker-dialog.component.d.ts(40,9): error TS1086: An accessor cannot be declared in an a
mbient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(30,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(31,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(32,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(34,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(35,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(37,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(38,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(43,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(46,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(47,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(49,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(50,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(80,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(81,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(82,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(83,9): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/mat-timepicker/lib/timepicker.directive.d.ts(84,17): error TS1086: An accessor cannot be declared in an ambient context.

You can help me with this please, thanks.

Object.values on IE

in file util.ts the Object.values() method is not supported by Internet Explorer.

Support anguar 11 ?

While migrating to Angular 11 there is an incompatibility issue with rxjs.

warning: Package "mat-timepicker" has an incompatible peer dependency to "rxjs" (requires "~6.5.4", would install "6.6.3").

Error extracting i18n message files

Hello I'm getting error when I try to extract localization message file using "ng xi18n".

You can try in your own demo application.
This trace is from your demo app:

ERROR in src/app/app.component.html(21,9): Directive MatTimepickerDirective, Property '_isServer' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(21,9): Directive MatTimepickerDirective, Property 'readonly' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(21,9): Directive MatTimepickerDirective, Property '_isNativeSelect' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(30,9): Directive MatTimepickerDirective, Property '_isServer' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(30,9): Directive MatTimepickerDirective, Property 'readonly' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(30,9): Directive MatTimepickerDirective, Property '_isNativeSelect' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(42,9): Directive MatTimepickerDirective, Property '_isServer' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(42,9): Directive MatTimepickerDirective, Property 'readonly' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(42,9): Directive MatTimepickerDirective, Property '_isNativeSelect' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(52,9): Directive MatTimepickerDirective, Property '_isServer' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(52,9): Directive MatTimepickerDirective, Property 'readonly' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(52,9): Directive MatTimepickerDirective, Property '_isNativeSelect' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(65,9): Directive MatTimepickerDirective, Property '_isServer' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(65,9): Directive MatTimepickerDirective, Property 'readonly' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(65,9): Directive MatTimepickerDirective, Property '_isNativeSelect' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(75,9): Directive MatTimepickerDirective, Property '_isServer' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(75,9): Directive MatTimepickerDirective, Property 'readonly' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(75,9): Directive MatTimepickerDirective, Property '_isNativeSelect' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(91,9): Directive MatTimepickerDirective, Property '_isServer' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(91,9): Directive MatTimepickerDirective, Property 'readonly' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(91,9): Directive MatTimepickerDirective, Property '_isNativeSelect' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(102,9): Directive MatTimepickerDirective, Property '_isServer' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(102,9): Directive MatTimepickerDirective, Property 'readonly' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(102,9): Directive MatTimepickerDirective, Property '_isNativeSelect' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(117,5): Directive MatTimepickerDirective, Property '_isServer' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(117,5): Directive MatTimepickerDirective, Property 'readonly' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(117,5): Directive MatTimepickerDirective, Property '_isNativeSelect' does not exist on type 'MatTimepickerDirective'.
src/app/app.component.html(21,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(21,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(21,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(30,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(30,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(30,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(42,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(42,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(42,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(52,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(52,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(52,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(65,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(65,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(65,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(75,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(75,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(75,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(91,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(91,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(91,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(102,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(102,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(102,9): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(117,5): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(117,5): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.
src/app/app.component.html(117,5): Directive MatTimepickerDirective, Expected 0 arguments, but got 1.

Cheers

Module not found: Error: Package path ./lib/clock/clock.component is not exported from package \node_modules\mat- timepicker (see exports field in node_modules\mat-timepicker\package.json)

We were using the ClockComponent on the 5.1.5 version, and was imported via the following:
import { ɵa as ClockComponent } from 'mat-timepicker';
Now when updating to Angular 14, and the 5.1.7 version we corrected the import to:
import { ClockComponent } from "mat-timepicker/lib/clock/clock.component";
However, this gives the following error:
Module not found: Error: Package path ./lib/clock/clock.component is not exported from package \node_modules\mat- timepicker (see exports field in node_modules\mat-timepicker\package.json)

And we can't seem to fix it at all.
Is the export wrong maybe? Not sure of what we can be doing wrong
Thanks

Typo in "mat-timepicker.component.ts"

When I try to set a minDate without setting the maxDate, the mat-timepicker crashes with the following message:

ModalSurveyStartComponent.html:12 ERROR TypeError: Cannot read property 'setSeconds' of undefined
at MatTimepickerComponent.ngOnInit (mat-timepicker.js:696)
at checkAndUpdateDirectiveInline (core.js:31910)
at checkAndUpdateNodeInline (core.js:44367)
at checkAndUpdateNode (core.js:44306)
at debugCheckAndUpdateNode (core.js:45328)
at debugCheckDirectivesFn (core.js:45271)
at Object.eval [as updateDirectives] (ModalSurveyStartComponent.html:21)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:45259)
at checkAndUpdateView (core.js:44271)

The reason (I suppose): There is a simple typo in the line 277

this:
if (hasMinDate || hasMinDate) {
if (hasMinDate) { this.minDate.setSeconds(0); this.minDate.setMilliseconds(0); }
if (hasMinDate) { this.maxDate.setSeconds(0); this.maxDate.setMilliseconds(0); }
this.calculateAllowedMap();
}

should be like this:
if (hasMinDate || hasMaxDate) {
if (hasMinDate) { this.minDate.setSeconds(0); this.minDate.setMilliseconds(0); }
if (hasMaxDate) { this.maxDate.setSeconds(0); this.maxDate.setMilliseconds(0); }
this.calculateAllowedMap();
}

Time format problems

Hi, i have this problem with the library, i select for example this hour (5:00 am) and the value return is 2020-11-23T10:00:00.000Z, this is not right need to be 2020-11-23T05:00:00.000Z, you can help me please, thanks

FormControl triggers statusChanges/valueChanges continuously when minDate and maxDate are specified

If the timepicker component is used not in template driven forms mode (i.e. not with ngModel binding but with an input formControl), the formControl status changes are always triggered although the value does not change.
This happens only if the minDate and maxDate are specified.

In html template
<input [class.color-transparent]="dialogOpen == true && !originalValue" matInput placeholder="{{placeholder | translate}}" [formControl]="timeFormControl" (timeChange)="focusIn == false ? timeChangeHandler('timechange') : ''" (invalidInput)="onInvalid($event)" (focusin)="focusIn = true" (focusout)="focusIn = false; timeChangeHandler('focus')" #t="matTimepicker" matTimepicker mode="24h" okLabel="{{okLabel | translate}}" cancelLabel="{{cancelLabel | translate}}" [disableDialogOpenOnClick]="true" [minDate]="minDate" [maxDate]="maxDate" [required]="required" >

In ts
@input() timeFormControl: FormControl = new FormControl(null);

` ngOnInit() {
moment.locale(this.translate.currentLang);

this.timeFormControl.statusChanges.subscribe((status : any) => {
  console.log("status changes ", status);
})

}`
The same happens for the valueChanges observable

Would it also be possible to accept undefined minDate and maxDate?

Thank you.

Support for time locale?

As far I can see locale support is limited to 24h/12h format with a hardcoded time format in 12h mode of "HH:mm [a|am|p|pm]" but not in all languages/country use am/pm.

Can you take a look to this improvement?

Thanks.

Doesn't build with Angular 14

How to reproduce on brand new project:

~/Temp
> ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 14.1.3
Node: 16.13.2
Package Manager: npm 8.18.0
OS: darwin arm64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1401.3 (cli-only)
@angular-devkit/core         14.1.3 (cli-only)
@angular-devkit/schematics   14.1.3 (cli-only)
@schematics/angular          14.1.3 (cli-only)


~/Temp
> ng new TimepickerTest --defaults
CREATE TimepickerTest/README.md (1068 bytes)
CREATE TimepickerTest/.editorconfig (274 bytes)
CREATE TimepickerTest/.gitignore (548 bytes)
CREATE TimepickerTest/angular.json (2963 bytes)
CREATE TimepickerTest/package.json (1046 bytes)
CREATE TimepickerTest/tsconfig.json (863 bytes)
CREATE TimepickerTest/.browserslistrc (600 bytes)
CREATE TimepickerTest/karma.conf.js (1432 bytes)
CREATE TimepickerTest/tsconfig.app.json (287 bytes)
CREATE TimepickerTest/tsconfig.spec.json (333 bytes)
CREATE TimepickerTest/.vscode/extensions.json (130 bytes)
CREATE TimepickerTest/.vscode/launch.json (474 bytes)
CREATE TimepickerTest/.vscode/tasks.json (938 bytes)
CREATE TimepickerTest/src/favicon.ico (948 bytes)
CREATE TimepickerTest/src/index.html (300 bytes)
CREATE TimepickerTest/src/main.ts (372 bytes)
CREATE TimepickerTest/src/polyfills.ts (2338 bytes)
CREATE TimepickerTest/src/styles.css (80 bytes)
CREATE TimepickerTest/src/test.ts (749 bytes)
CREATE TimepickerTest/src/assets/.gitkeep (0 bytes)
CREATE TimepickerTest/src/environments/environment.prod.ts (51 bytes)
CREATE TimepickerTest/src/environments/environment.ts (658 bytes)
CREATE TimepickerTest/src/app/app.module.ts (314 bytes)
CREATE TimepickerTest/src/app/app.component.css (0 bytes)
CREATE TimepickerTest/src/app/app.component.html (23083 bytes)
CREATE TimepickerTest/src/app/app.component.spec.ts (980 bytes)
CREATE TimepickerTest/src/app/app.component.ts (218 bytes)
✔ Packages installed successfully.
    Successfully initialized git.

~/Temp                                                                                                          took 7s
> cd TimepickerTest

~/Temp/TimepickerTest on master
> npm i mat-timepicker
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"^14.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^12.0.0 || ^13.0.0-0" from @angular/[email protected]
npm ERR! node_modules/@angular/cdk
npm ERR!   peer @angular/cdk@"^12.2.13" from [email protected]
npm ERR!   node_modules/mat-timepicker
npm ERR!     mat-timepicker@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/boris/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/boris/.npm/_logs/2022-08-23T10_56_38_880Z-debug-0.log

By forking the repo and changing versions to 14 in projects/mat-timepicker/package.json it managed to install, but fails to compile with many errors.

Change buttons styling

Hi,

is it possible to change buttons styling without some heavy hacking? We are utilizing mat-stroked button within the application and the dialog buttons don't meet that requirement.

Thanks

Value at position 1 in the NgModule.imports of MatTimepickerModule is not a reference: [object Object]

I am trying to run the timepicker in my Angular 9 up but I cannot compile it as it seem.

The error I get is:

node_modules/mat-timepicker/fesm2015/mat-timepicker.js:1197:26 - error NG1010: 
Value at position 1 in the NgModule.imports of MatTimepickerModule is not a reference: [object Object]

1197                 imports: [
                              ~
1198                     CommonModule,
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ... 
1203                     MatInputModule
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1204                 ],
     ~~~~~~~~~~~~~~~~~

Any idea how this can be fixed?

These are my dependencies:

"@agm/core": "^1.1.0",
"@angular/animations": "9.1.2",
"@angular/cdk": "^9.2.1",
"@angular/common": "9.1.2",
"@angular/compiler": "9.1.2",
"@angular/core": "9.1.2",
"@angular/flex-layout": "^9.0.0-beta.29",
"@angular/forms": "9.1.2",
"@angular/http": "7.2.16",
"@angular/localize": "^9.1.2",
"@angular/material": "^9.2.1",
"@angular/material-moment-adapter": "^9.2.1",
"@angular/platform-browser": "9.1.2",
"@angular/platform-browser-dynamic": "9.1.2",
"@angular/router": "9.1.2",
"@fortawesome/angular-fontawesome": "^0.6.1",
"@fortawesome/fontawesome-svg-core": "^1.2.28",
"@fortawesome/free-brands-svg-icons": "^5.13.0",
"@fortawesome/free-solid-svg-icons": "^5.13.0",
"@ngx-share/button": "^7.1.4",
"@ngx-share/core": "^7.1.4",
"angular-mentions": "^1.1.6",
"chart.js": "^2.9.3",
"core-js": "^3.6.5",
"express": "^4.17.1",
"http-server": "^0.12.1",
"http-status-codes": "^1.4.0",
"mahlzeiten-rest-client": "./generated/mahlzeiten-rest-client",
"mat-timepicker": "^2.0.2",
"moment": "^2.24.0",
"ng2-adsense": "^7.0.0",
"ngx-captcha": "^8.0.1",
"ngx-logger": "^4.1.8",
"ngx-moment": "^3.5.0",
"rxjs": "^6.5.5",
"tslib": "^1.11.1",
"typescript": "3.8.3",
"uuid": "^7.0.3",
"zone.js": "^0.10.3"

Angular 9

Please can you update your package to support Angular 9?

Many thanks

12h mode doesnt work with reactive forms when initialized

This is also happening in the demo app on stackblitz, in the latest example.

Demo:
TS:
// in constructor
const d = new Date();
d.setDate(1);
d.setMonth(2);
d.setHours(14);
d.setMinutes(0);
d.setSeconds(1);
d.setMilliseconds(10);
this.defaultValue = d;

this.form = this.formBuilder.group({
  time: [this.defaultValue, Validators.required]
});

HTML:

Time
Reactive Form Value: {{form.value | json}}
{{form.get('time').errors | json}} Change Max Value

Expect:
When setting default value through form control, expected input to be in "hh:mm am/pm" format (2:00 pm).

Actuall:
Input is defaulted to 24h hh:mm format (14:00) even when 12h mode is set

Reason:
when selecting 12h mode the 24h mode is still selected when rendering default input value in
@input() set value(value: Date){...}

Change primary color

Changing the property color with a hexadecimal value like ##FF5733 doesn't change the main color.

Allow binding with moment like angular material datepicker

Angular material datepicker allows it, why not angular material timepicker ?

Moment has more advanced features over native Date.

<mat-form-field>
  <mat-label>Birthdate</mat-label>
  <input matInput [matDatepicker]="picker" [(ngModel)]="birthMoment" />
  <mat-datepicker-toggle matSuffix [for]="picker"> </mat-datepicker-toggle>
  <mat-datepicker #picker></mat-datepicker>
</mat-form-field>

in TS:

birthMoment: moment.Moment;

in Module:

import { MatMomentDateModule } from '@angular/material-moment-adapter';

@NgModule({
  imports: [
    // MatNativeDateModule, 
    MatMomentDateModule, 

Could you support JSON value?

Material Angular Datepicker supports JSON values. It is easy to initialize directly from the database. Could you incorporate initialization through a JSON Date value?

For example: when you call:

this.control.setValue("2020-09-25T19:00:00-03:00")

you get:

ERROR TypeError: value.setSeconds is not a function
    at MatTimepickerDirective.writeValue (mat-timepicker.js:917)

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.