Skip to content

Commit 99c493e

Browse files
committed
fix(datetime): set disabled state from FormControl
1 parent b44ff41 commit 99c493e

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

src/components/datetime/datetime.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,13 @@ export class DateTime extends Ion implements AfterContentInit, ControlValueAcces
860860
*/
861861
onTouched() { }
862862

863+
/**
864+
* @private
865+
*/
866+
setDisabledState(isDisabled: boolean) {
867+
this.disabled = isDisabled;
868+
}
869+
863870
/**
864871
* @private
865872
*/
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { Component, NgModule } from '@angular/core';
2+
import { FormControl, FormGroup } from '@angular/forms';
3+
import { IonicApp, IonicModule } from '../../../..';
4+
5+
6+
7+
@Component({
8+
templateUrl: 'main.html'
9+
})
10+
export class E2EPage {
11+
stackedCtrl = new FormControl('1994-12-15T13:47:20.789');
12+
floatingCtrl = new FormControl('1995-04-15');
13+
fixedCtrl = new FormControl({value: '2002-09-23T15:03:46.789', disabled: true});
14+
inlineCtrl = new FormControl({value: '2005-06-17T11:06Z', disabled: true});
15+
16+
datetimeForm = new FormGroup({
17+
'stacked': this.stackedCtrl,
18+
'floating': this.floatingCtrl,
19+
'fixed': this.fixedCtrl,
20+
'inline': this.inlineCtrl
21+
});
22+
23+
}
24+
25+
26+
@Component({
27+
template: '<ion-nav [root]="root"></ion-nav>'
28+
})
29+
export class E2EApp {
30+
root = E2EPage;
31+
}
32+
33+
@NgModule({
34+
declarations: [
35+
E2EApp,
36+
E2EPage
37+
],
38+
imports: [
39+
IonicModule.forRoot(E2EApp)
40+
],
41+
bootstrap: [IonicApp],
42+
entryComponents: [
43+
E2EPage
44+
]
45+
})
46+
export class AppModule {}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<ion-header>
2+
3+
<ion-toolbar>
4+
<ion-title>Datetime</ion-title>
5+
</ion-toolbar>
6+
7+
</ion-header>
8+
9+
10+
<ion-content class="outer-content">
11+
<form [formGroup]="datetimeForm">
12+
<ion-item>
13+
<ion-label stacked>Stacked</ion-label>
14+
<ion-datetime formControlName="stacked"></ion-datetime>
15+
</ion-item>
16+
17+
<ion-item>
18+
<ion-label floating>Floating</ion-label>
19+
<ion-datetime formControlName="floating" displayFormat="MMMM YY"></ion-datetime>
20+
</ion-item>
21+
22+
<ion-item>
23+
<ion-label fixed>Fixed</ion-label>
24+
<ion-datetime formControlName="fixed" displayFormat="MM/DD/YYYY"></ion-datetime>
25+
</ion-item>
26+
27+
<ion-item>
28+
<ion-label>Inline</ion-label>
29+
<ion-datetime formControlName="inline" displayFormat="MM/DD/YYYY"></ion-datetime>
30+
</ion-item>
31+
</form>
32+
</ion-content>

0 commit comments

Comments
 (0)