Skip to content

Commit

Permalink
fix(datetime): use spread operator to copy pickerOptions (#13202)
Browse files Browse the repository at this point in the history
* fix(datetime): use spread operator to copy pickerOptions to keep functions

* style(datetime): fix typo in comment

fixes #11641
  • Loading branch information
brandyscarney authored and manucorporat committed Oct 27, 2017
1 parent 616786b commit 2ab8385
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/datetime/datetime.ts
Expand Up @@ -522,8 +522,8 @@ export class DateTime extends BaseInput<DateTimeData> implements AfterContentIni

console.debug('datetime, open picker');

// the user may have assigned some options specifically for the alert
const pickerOptions = deepCopy(this.pickerOptions);
// the user may have assigned some options specifically for the picker
const pickerOptions = {...this.pickerOptions};

// Configure picker under the hood
const picker = this._picker = this._pickerCtrl.create(pickerOptions);
Expand Down
Expand Up @@ -16,7 +16,7 @@

<ion-item>
<ion-label>MM DD YY</ion-label>
<ion-datetime pickerFormat="YYYY-MM-DDThh:mm" [(ngModel)]="placeholderDate" placeholder="Select Date"></ion-datetime>
<ion-datetime pickerFormat="YYYY-MM-DDThh:mm" [pickerOptions]="customOptions" [(ngModel)]="placeholderDate" placeholder="Select Date"></ion-datetime>
</ion-item>

<ion-item>
Expand Down
10 changes: 10 additions & 0 deletions src/components/datetime/test/basic/pages/root-page/root-page.ts
Expand Up @@ -31,6 +31,16 @@ export class RootPage {
'l\u00f8r'
];

customOptions: any = {
buttons: [{
text: 'Save',
handler: () => console.log('Clicked Save!')
}, {
text: 'Log',
handler: () => console.log('Clicked Log!')
}]
};

onChange(ev: any) {
console.log('Changed', ev);
}
Expand Down

0 comments on commit 2ab8385

Please sign in to comment.