Skip to content

Commit 68b6e27

Browse files
committed
feat(example): Updating example with validDates
1 parent 1abec99 commit 68b6e27

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/app/app.component.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,33 @@ <h4>{{ model4 }}</h4>
120120
</div>
121121
</div>
122122
</div>
123+
124+
<h2>Valid dates</h2>
125+
126+
<p>
127+
Today, tomorrow and the same to the next month are valid, all others are disabled.
128+
</p>
129+
130+
<pre>{{validDates | json}}</pre>
131+
132+
<div class="container">
133+
<dd-ngxdatepicker
134+
name="model5"
135+
[(ngModel)]="model5"
136+
[validDates]="validDates"
137+
(dateClicked)="date5 = $event"
138+
>
139+
</dd-ngxdatepicker>
140+
141+
<div class="container-info">
142+
<div>
143+
<h3>[(dateClicked)]</h3>
144+
<h4>{{ date5 }}</h4>
145+
</div>
146+
147+
<div>
148+
<h3>[(ngModel)]</h3>
149+
<h4>{{ model5 }}</h4>
150+
</div>
151+
</div>
152+
</div>

src/app/app.component.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class AppComponent implements OnInit {
1010
@ViewChild('datepicker') datepicker: any;
1111
@ViewChild('datepicker2') datepicker2: any;
1212
invalidDates: string[] = [];
13+
validDates: string[] = [];
1314

1415
date: string;
1516
model: any = moment('29/11/2020', 'DD/MM/YYYY').format();
@@ -23,10 +24,24 @@ export class AppComponent implements OnInit {
2324
date4: string;
2425
model4: any = moment().format();
2526

27+
date5: string;
28+
model5: any = moment().format();
29+
2630
ngOnInit() {
2731
const tomorrow = moment().add(1, 'days').format();
2832
const someDayOfNextMonth = moment().add(1, 'month').format();
2933
this.invalidDates.push(tomorrow);
3034
this.invalidDates.push(someDayOfNextMonth);
35+
36+
const today = moment().format();
37+
const oneMonthFromNow = moment().add(1, 'months').format();
38+
const oneMonthFromNowPlusOneDay = moment().add(1, 'months').add(1, 'days').format();
39+
40+
this.validDates = [
41+
today,
42+
tomorrow,
43+
oneMonthFromNow,
44+
oneMonthFromNowPlusOneDay
45+
];
3146
}
3247
}

0 commit comments

Comments
 (0)