Skip to content

Commit

Permalink
set date change hook in <date-picker> component
Browse files Browse the repository at this point in the history
closes #4
  • Loading branch information
changhuixu committed Nov 5, 2018
1 parent 60c573e commit f4ef867
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
6 changes: 3 additions & 3 deletions projects/uiowa/date-range-picker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@uiowa/date-range-picker",
"version": "1.1.2",
"version": "1.1.3",
"author": "Changhui Xu <[email protected]>",
"contributors": [
"Jacob Feuerbach <[email protected]>"
Expand All @@ -13,8 +13,8 @@
},
"license": "MIT",
"peerDependencies": {
"@angular/common": "^6.0.0-rc.0 || ^6.0.0",
"@angular/core": "^6.0.0-rc.0 || ^6.0.0",
"@angular/common": ">=6.0.0",
"@angular/core": ">=6.0.0",
"@ng-bootstrap/ng-bootstrap": ">=3.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import {
Component,
OnInit,
Input,
Output,
EventEmitter,
OnChanges,
SimpleChanges
} from '@angular/core';
import { NgbDateNativeAdapter } from '../services/NgbDateNativeAdapter';
import { NgbDate } from '@ng-bootstrap/ng-bootstrap';

Expand All @@ -7,7 +15,7 @@ import { NgbDate } from '@ng-bootstrap/ng-bootstrap';
templateUrl: './date-picker.component.html',
styleUrls: ['./date-picker.component.css']
})
export class DatePickerComponent implements OnInit {
export class DatePickerComponent implements OnInit, OnChanges {
@Input()
date: Date;

Expand All @@ -22,6 +30,12 @@ export class DatePickerComponent implements OnInit {
this.ngbDate = this.dateAdapter.fromModel(this.date);
}

ngOnChanges(changes: SimpleChanges): void {
if (changes.date) {
this.ngOnInit();
}
}

onDateChange(date: NgbDate) {
this.dateChange.emit(this.dateAdapter.toModel(date));
}
Expand Down

0 comments on commit f4ef867

Please sign in to comment.