-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
11,162 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.vs | ||
.code | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,182 @@ | ||
# ngx-calendar | ||
# ngx-calendar | ||
|
||
### Description | ||
|
||
Calendar component for Angular. | ||
|
||
### Demo | ||
|
||
- [StackBlitz](https://stackblitz.com/edit/ngx-calendar-demo) | ||
|
||
### Requirements | ||
|
||
- [Moment.js](https://momentjs.com/) | ||
- [Angular](https://angular.io/) | ||
|
||
### Install | ||
|
||
- **NPM** | ||
|
||
``` | ||
npm install ss-ngx-calendar | ||
``` | ||
|
||
### Setup | ||
|
||
```javascript | ||
import { NgModule } from "@angular/core"; | ||
import { CommonModule } from "@angular/common"; | ||
|
||
import { NgxCalendarModule } from "ngx-calendar"; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
|
||
NgxCalendarModule | ||
] | ||
}) | ||
export class AppModule { } | ||
``` | ||
|
||
### Usage | ||
|
||
```javascript | ||
calendarOptions = {}; | ||
|
||
calendarValue = null; | ||
|
||
onChooseDate(date: any) { | ||
this.calendarValue = date; | ||
} | ||
``` | ||
|
||
```html | ||
<ngx-calendar [options]="calendarOptions" (onChooseDate)="onChooseDate($event)"></ngx-calendar> | ||
``` | ||
|
||
### Options | ||
|
||
- **Week view (No time.)**<br>Use to switch to week view mode. | ||
|
||
```javascript | ||
calendarOptions = { isWeek: true }; | ||
``` | ||
|
||
- **Week view (With time.)**<br>Use to add time to week view mode. | ||
|
||
```javascript | ||
calendarOptions = { isWeek: true, isWithTime: true }; | ||
``` | ||
|
||
> **WARNING**: Options described from now will be working just for the week view mode with time. | ||
- **Available date range**<br>Use to hide times, not within this range. | ||
- Also, disables arrow to change a week, if there are no available times. | ||
|
||
```javascript | ||
calendarOptions = { isWeek: true, isWithTime: true, fromDate: moment(), toDate: moment().add(1, "M") }; | ||
|
||
//If you need to set fromDate: moment(), just use isFromNow: true. | ||
``` | ||
|
||
- **Available time range**<br>Use to hide hours, not within this range. | ||
- Default is from 0 to 23. | ||
|
||
```javascript | ||
calendarOptions = { isWeek: true, isWithTime: true, fromHour: 7, toHour: 19 }; | ||
``` | ||
|
||
- **Interval**<br>Use to generate hours with some interval. | ||
- Default is 1 hour. | ||
|
||
```javascript | ||
calendarOptions = { isWeek: true, isWithTime: true, hourInterval: 2, minuteInterval: 30 }; | ||
``` | ||
|
||
### Additional | ||
|
||
- **Events**<br>Use to highlight the date. | ||
- **WARNING**: Just for month view mode. | ||
|
||
```javascript | ||
calendarOptions = {}; | ||
|
||
calendarEvents = [moment(), "2022-07-12"]; | ||
``` | ||
|
||
```html | ||
<ngx-calendar [options]="calendarOptions" [events]="calendarEvents"></ngx-calendar> | ||
``` | ||
|
||
- **Get date range**<br>Use to get date range and watch changes after clicking on arrows. | ||
|
||
```javascript | ||
calendarOptions = {}; | ||
|
||
onChangeDate(dateRange: any) { | ||
//dateRange is an object with fromDate and toDate properties as moment objects. | ||
} | ||
``` | ||
|
||
```html | ||
<ngx-calendar [options]="calendarOptions" (onChangeDate)="onChangeDate($event)"></ngx-calendar> | ||
``` | ||
|
||
- **Get chosen date**<br>Use to get chosen date after clicking on one. | ||
- Clicking on one date two times will clear it. | ||
|
||
```javascript | ||
calendarOptions = {}; | ||
|
||
onChooseDate(date: any) { | ||
//date is a chosen date as moment object or null. | ||
} | ||
``` | ||
|
||
```html | ||
<ngx-calendar [options]="calendarOptions" (onChooseDate)="onChooseDate($event)"></ngx-calendar> | ||
``` | ||
|
||
- **Change view**<br>Use to change view after load. | ||
|
||
```javascript | ||
import { NgxCalendarComponent } from "ngx-calendar"; | ||
|
||
@ViewChild("ngxCalendar") ngxCalendar: NgxCalendarComponent; | ||
|
||
calendarOptions = {}; | ||
|
||
//After the calendar is initialized. | ||
ngAfterViewInit() { | ||
var isMonth = false; //To change to week view mode. | ||
|
||
this.ngxCalendar.setView(isMonth); | ||
} | ||
|
||
``` | ||
|
||
```html | ||
<ngx-calendar #ngxCalendar [options]="calendarOptions"></ngx-calendar> | ||
``` | ||
|
||
- **Refresh**<br>Use to reload options in case of change. | ||
|
||
```javascript | ||
import { NgxCalendarComponent } from "ngx-calendar"; | ||
|
||
@ViewChild("ngxCalendar") ngxCalendar: NgxCalendarComponent; | ||
|
||
calendarOptions = {}; | ||
|
||
//After the calendar is initialized. | ||
ngAfterViewInit() { | ||
this.calendarOptions = { isWeek: true, isWithTime: true, fromHour: 8, toHour: 17 }; | ||
|
||
this.ngxCalendar.refresh(); | ||
} | ||
``` | ||
|
||
```html | ||
<ngx-calendar #ngxCalendar [options]="calendarOptions"></ngx-calendar> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"version": 1, | ||
"newProjectRoot": "projects", | ||
"projects": { | ||
"ngx-calendar-app": { | ||
"root": "", | ||
"sourceRoot": "src", | ||
"projectType": "application", | ||
"prefix": "app", | ||
"schematics": { | ||
"@schematics/angular:component": { | ||
"styleext": "scss" | ||
} | ||
}, | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-devkit/build-angular:browser", | ||
"options": { | ||
"outputPath": "dist/ngx-calendar-app", | ||
"index": "src/index.html", | ||
"main": "src/main.ts", | ||
"polyfills": "src/polyfills.ts", | ||
"tsConfig": "src/tsconfig.app.json", | ||
"assets": [], | ||
"styles": [ | ||
"src/index.scss" | ||
], | ||
"scripts": [] | ||
}, | ||
"configurations": { | ||
"production": { | ||
"fileReplacements": [{ | ||
"replace": "src/environments/environment.ts", | ||
"with": "src/environments/environment.prod.ts" | ||
}], | ||
"optimization": true, | ||
"outputHashing": "all", | ||
"sourceMap": false, | ||
"extractCss": true, | ||
"namedChunks": false, | ||
"aot": true, | ||
"extractLicenses": true, | ||
"vendorChunk": false, | ||
"buildOptimizer": true | ||
} | ||
} | ||
}, | ||
"serve": { | ||
"builder": "@angular-devkit/build-angular:dev-server", | ||
"options": { | ||
"browserTarget": "ngx-calendar-app:build" | ||
}, | ||
"configurations": { | ||
"production": { | ||
"browserTarget": "ngx-calendar-app:build:production" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"ngx-calendar": { | ||
"root": "projects/ngx-calendar", | ||
"sourceRoot": "projects/ngx-calendar/src", | ||
"projectType": "library", | ||
"prefix": "lib", | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-devkit/build-ng-packagr:build", | ||
"options": { | ||
"tsConfig": "projects/ngx-calendar/tsconfig.lib.json", | ||
"project": "projects/ngx-calendar/ng-package.json" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"defaultProject": "ngx-calendar-app" | ||
} |
Oops, something went wrong.