
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
mat-datepicker-time-header
Advanced tools
default angular material datepicker header with an added time input
npm i mat-datepicker-time-header
import { MatNativeDateModule } from '@angular/material/core';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatDatepickerTimeHeaderModule } from 'mat-datepicker-time-header';
@NgModule({
imports: [
MatNativeDateModule,
MatDatepickerModule,
// the module for this lib
MatDatepickerTimeHeaderModule
],
entryComponents: [
// if you get an error, you may need to add the component to the entryComponents array
MatDatepickerTimeHeaderComponent
]
})
In order for the input to work, you must add a control with the name time
to a formGroup
, and add the formGroup on one of the parents of the datepicker. Otherwise it will just throw an error. The cotrol name can optionaly be configured.
in component.ts
formGroup
with a time
controlform = new FormGroup({ date: new FormControl(), time: new FormControl() });
import { MatDatepickerTimeHeaderComponent } from "mat-datepicker-time-header";
timeHeader = MatDatepickerTimeHeaderComponent;
in component.html
<form [formGroup]="form">
<mat-form-field appearance="fill">
<mat-label>Custom calendar header</mat-label>
<input formControlName="date" matInput [matDatepicker]="picker" />
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
</form>
<mat-datepicker #picker [calendarHeaderComponent]="timeHeader"></mat-datepicker>
By default, the time input will search for a parent formGroup and attach itself to the control with the name time
,
the control name can optionaly be changed by providing the control name.
import { MAT_DATEPICKER_TIME_CONTROL_NAME } from "mat-datepicker-time-header";
providers: [
{ provide: MAT_DATEPICKER_TIME_CONTROL_NAME, useValue: "event_time" },
// now it will attach to "event_time" instead
];
Pull requests welcome
FAQs
default angular material datepicker header with an added time input
We found that mat-datepicker-time-header demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.