$ npm install angular-kalendar
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { AngularKalendarModule } from 'angular-kalendar';
@NgModule({
imports: [AngularKalendarModule, BrowserModule],
exports: [],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: [],
})
export class AppModule { }
<angular-kalendar></angular-kalendar>
<angular-kalendar [(ngModel)]="date" (ngModelChange)="doSomething()"></angular-kalendar>
...
export class Component implements OnInit {
date: Date;
}
<form [formGroup]="formGroup" (ngSubmit)="onSubmit()">
<angular-kalendar [formControl]="formGroup.get('date')"></angular-kalendar>
<button type="submit">SUBMIT</button>
<button type="button" (click)="reset()">Reset</button>
</form>
...
export class FormGroupComponent implements OnInit {
formGroup: FormGroup;
ngOnInit() {
this.formGroup = new FormGroup({
'date': new FormControl(new Date())
});
}
onSubmit(): void {
//do something
}
reset(): void {
this.formGroup.reset({
'date': new Date()
});
}
}
Angular Kalendar accepts an input called 'options'
<angular-kalendar [options]="myOptions"></angular-kalendar>
...
import { KalendarOptions } from 'angular-kalendar';
export class Hours12Component implements OnInit {
options: KalendarOptions = {
format: 'dd.mm.yyyy',
showTimepicker: false
}
}
interface KalendarOptions {
format?: string,
hours24?: boolean,
showTimepicker?: boolean
}
DEFAULT: 'yyyy-mm-dd H:MM'
Format string accepts the following values
Format String | Description |
---|---|
d | day of the month |
dd | day of the month, zero padded |
m | month (eg. 3) |
mm | month, zero padded (eg. 03) |
mmm | month text, short (eg. Mar) |
mmmm | month text, long (eg. March) |
yy | double digit year (eg. 2007 becomes 07) |
yyyy | full year (eg. 2007) |
H | hour value |
HH | hour value, zero padded |
MM | minute value |
Examples: |
- dd.mm.yyyy -> 03.01.1997
- m/d/yy -> 1/3/97
- yyyy-mm-dd H:MM -> 1997-01-03 15:38
DEFAULT: true.
If true, display hours 0-23 If false, display hours 1-12 AM, 1-12 PM
DEFAULT: true.
If true, show the timepicker under the calendar If false, don't
Don't like the way it looks? You can override the existing styles in the following manners
@Component({
selector: 'my-component',
template: `
<angular-kalendar class="kalendar"></angular-kalendar>
`,
styles: [`
:host /deep/ .kalendar .ang2cal-btn:hover {
background-color: blue;
color: white;
border-radius: 0;
}
`]
})
In angular-cli.json
styles: [
"styles.css"
]
In styles.css
.kalendar .ang2cal-day {
background-color: pink;
border: 1px solid grey;
border-radius: 0;
}