Skip to content

Commit

Permalink
Year set in maxyear first to minyear order closes logisticinfotech#2
Browse files Browse the repository at this point in the history
  • Loading branch information
chintan13 committed Jan 23, 2019
1 parent cf66e6d commit 63a7bf1
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion projects/ionic4-datepicker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@logisticinfotech/ionic4-datepicker",
"version": "1.0.6",
"version": "1.0.7",
"description": "ionic4-datepicker inspired by rajeshwar patlolla ionic1 datepicker",
"keywords" :["Angular","Library", "Ionic4", "Datepicker"],
"license" : "SEE LICENSE IN LICENSE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,13 @@ export class Ionic4DatepickerModalComponent implements OnInit {
// console.log('getYearsList =>', from, to);
// tslint:disable-next-line:prefer-const
let yearsList = [];
let minYear = 1900;
let minYear = 1950;
// let maxYear = 2100;
// let minYear = 2000;
let maxYear = new Date().getFullYear() + 1;
minYear = from ? new Date(from).getFullYear() : minYear;
maxYear = to ? new Date(to).getFullYear() : maxYear;
for (let i = minYear; i <= maxYear; i++) {
for (let i = maxYear; i >= minYear; i--) {
yearsList.push(i);
}
return yearsList;
Expand Down
10 changes: 5 additions & 5 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [
{
path: '',
redirectTo: 'reactive-form',
redirectTo: 'home',
pathMatch: 'full'
},
// {
// path: 'home',
// loadChildren: './home/home.module#HomePageModule'
// },
{
path: 'home',
loadChildren: './home/home.module#HomePageModule'
},
{
path: 'reactive-form',
loadChildren: './reactive-form/reactive-form.module#ReactiveFormPageModule'
Expand Down
3 changes: 2 additions & 1 deletion src/app/home/home.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@

<ion-content padding>
<li-ionic4-datepicker [(ngModel)]="mydate" [inputDateConfig]="datePickerObj"></li-ionic4-datepicker>
<ion-input [(ngModel)]="date" [liIonic4Datepicker]="datePickerObj" style="border: 1px solid black;margin: 10px;"></ion-input>
<ion-input [(ngModel)]="mydate" (ionChange)="onChangeDate()"
[liIonic4Datepicker]="datePickerObj" style="border: 1px solid black;margin: 10px;"></ion-input>
</ion-content>
25 changes: 8 additions & 17 deletions src/app/home/home.page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms';

export class MyTemplateDriverForm {
public name: string;
Expand All @@ -15,27 +14,15 @@ export class MyTemplateDriverForm {
})
export class HomePage implements OnInit {

dataForm: FormGroup;

mydate = '11 Dec 2018';
// mydate;
date;

datePickerObj: any = {};

monthsList = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
weeksList = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];

myTemplateDriverForm: MyTemplateDriverForm;
constructor(
public formBuilder: FormBuilder
) {
this.dataForm = formBuilder.group({
name: new FormControl('', [Validators.required]),
email: new FormControl('', [Validators.required, Validators.email]),
date: new FormControl('2018-12-12', [Validators.required]),
});
constructor() {

this.myTemplateDriverForm = new MyTemplateDriverForm();
}

ngOnInit() {
Expand All @@ -52,7 +39,7 @@ export class HomePage implements OnInit {
// EXAMPLE OBJECT
this.datePickerObj = {
// inputDate: this.mydate,
// dateFormat: 'yyyy-MM-dd',
dateFormat: 'yyyy-MM-dd',
// fromDate: new Date('2018-12-08'), // default null
// toDate: new Date('2018-12-28'), // default null
// showTodayButton: true, // default true
Expand All @@ -69,7 +56,11 @@ export class HomePage implements OnInit {
};
}

onChangeDate() {
console.log("onChangeDate date ", this.mydate);
}

onClickSubmit() {
console.log('onClickSubmit', this.dataForm.value);
// console.log('onClickSubmit', this.dataForm.value);
}
}
4 changes: 3 additions & 1 deletion src/app/reactive-form/reactive-form.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
<ion-col size="12">
<ion-item>
<ion-label position="floating">Date : (using directive)</ion-label>
<ion-input [liIonic4Datepicker]="datePickerObj" type="text" formControlName="date"></ion-input>
<ion-input [liIonic4Datepicker]="datePickerObj" type="text"
formControlName="date"
(ionChange)="onChangeDate()"></ion-input>
</ion-item>
</ion-col>
<ion-col size="12">
Expand Down
8 changes: 6 additions & 2 deletions src/app/reactive-form/reactive-form.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export class ReactiveFormPage implements OnInit {
];

this.datePickerObj = {
fromDate: new Date('2018-12-20'), // need this in order to have toDate
toDate: new Date('2018-12-25'),
fromDate: new Date('2015-12-20'), // need this in order to have toDate
toDate: new Date('2019-12-25'),
showTodayButton: false,
closeOnSelect: true,
disableWeekDays: [],
Expand Down Expand Up @@ -76,6 +76,10 @@ export class ReactiveFormPage implements OnInit {
// };
}

onChangeDate() {
console.log("onChangeDate date ", this.dataForm.get('date').value);
}

onClickSubmit() {
console.log('onClickSubmit', this.dataForm.value);
}
Expand Down

0 comments on commit 63a7bf1

Please sign in to comment.