Skip to content

Commit

Permalink
fix(datetime): set disabled state from FormControl
Browse files Browse the repository at this point in the history
  • Loading branch information
brandyscarney committed Jan 12, 2017
1 parent b44ff41 commit 99c493e
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/datetime/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,13 @@ export class DateTime extends Ion implements AfterContentInit, ControlValueAcces
*/
onTouched() { }

/**
* @private
*/
setDisabledState(isDisabled: boolean) {
this.disabled = isDisabled;
}

/**
* @private
*/
Expand Down
46 changes: 46 additions & 0 deletions src/components/datetime/test/form/app-module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Component, NgModule } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { IonicApp, IonicModule } from '../../../..';



@Component({
templateUrl: 'main.html'
})
export class E2EPage {
stackedCtrl = new FormControl('1994-12-15T13:47:20.789');
floatingCtrl = new FormControl('1995-04-15');
fixedCtrl = new FormControl({value: '2002-09-23T15:03:46.789', disabled: true});
inlineCtrl = new FormControl({value: '2005-06-17T11:06Z', disabled: true});

datetimeForm = new FormGroup({
'stacked': this.stackedCtrl,
'floating': this.floatingCtrl,
'fixed': this.fixedCtrl,
'inline': this.inlineCtrl
});

}


@Component({
template: '<ion-nav [root]="root"></ion-nav>'
})
export class E2EApp {
root = E2EPage;
}

@NgModule({
declarations: [
E2EApp,
E2EPage
],
imports: [
IonicModule.forRoot(E2EApp)
],
bootstrap: [IonicApp],
entryComponents: [
E2EPage
]
})
export class AppModule {}
32 changes: 32 additions & 0 deletions src/components/datetime/test/form/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<ion-header>

<ion-toolbar>
<ion-title>Datetime</ion-title>
</ion-toolbar>

</ion-header>


<ion-content class="outer-content">
<form [formGroup]="datetimeForm">
<ion-item>
<ion-label stacked>Stacked</ion-label>
<ion-datetime formControlName="stacked"></ion-datetime>
</ion-item>

<ion-item>
<ion-label floating>Floating</ion-label>
<ion-datetime formControlName="floating" displayFormat="MMMM YY"></ion-datetime>
</ion-item>

<ion-item>
<ion-label fixed>Fixed</ion-label>
<ion-datetime formControlName="fixed" displayFormat="MM/DD/YYYY"></ion-datetime>
</ion-item>

<ion-item>
<ion-label>Inline</ion-label>
<ion-datetime formControlName="inline" displayFormat="MM/DD/YYYY"></ion-datetime>
</ion-item>
</form>
</ion-content>

0 comments on commit 99c493e

Please sign in to comment.