Skip to content

Commit

Permalink
Resolve bug with opened state not being part of changeDetection
Browse files Browse the repository at this point in the history
  • Loading branch information
ghetolay committed Nov 5, 2016
1 parent a80af36 commit 43e9fc0
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/components/ionic/datepickerionic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, ElementRef, OnInit, Renderer, ChangeDetectorRef } from '@angular/core';
import { Component, Input, ElementRef, OnInit, Renderer, ChangeDetectorRef, Optional } from '@angular/core';

import * as moment from 'moment';

Expand All @@ -18,7 +18,7 @@ export class DatePickerIonicComponent extends DatePickerTemplate<BaseSelect<any>
return extendConfig(
super.extendConfig({
templateUrl: './ionic.component.html',
styleUrls: ['ionic.scss'],
styleUrls: ['ionic.css'],
inputs: ['class', 'expanded', 'opened', 'viewFormat']
}, componentClass),
config
Expand All @@ -37,14 +37,25 @@ export class DatePickerIonicComponent extends DatePickerTemplate<BaseSelect<any>
this._class = DatePickerIonicComponent.CONTAINER_CLASS + ' ' + classStr;
}

/*@Input()*/ expanded: boolean;
/*@Input()*/ opened = false;
private _opened = false;
get opened() {
return this._opened;
}

/*@Input()*/ viewFormat = 'LL';
/*@Input()*/
set opened(b: boolean){
if( this._opened !== b ) {
this._opened = b;
this.cd.markForCheck();
}
}

/*@Input()*/ expanded: boolean;
/*@Input()*/ viewFormat = 'LL';

private el: Element;

constructor(renderer: Renderer, elRef: ElementRef, cd: ChangeDetectorRef, select: BaseSelect<any>) {
constructor(renderer: Renderer, elRef: ElementRef, cd: ChangeDetectorRef, @Optional() select: BaseSelect<any>) {
super(cd, select);

this.el = elRef.nativeElement;
Expand Down

0 comments on commit 43e9fc0

Please sign in to comment.