Skip to content

Commit

Permalink
Merge pull request #7 from Romko775/IS-6
Browse files Browse the repository at this point in the history
Fix issue #6
  • Loading branch information
Romko775 committed Mar 27, 2019
2 parents 67514f9 + c5f9540 commit 6911fab
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class AppModule { }
| ------------- | ------------- | ------------- | ------------- | ------------- |
|[customPlaceholderText] | `string` | `Choose...` | no | Allows you to localize the placeholder text. |
|[getUserZone] | `boolean` | `false` | no | Allows you to guess user timezone. If `true` also emits value on init. |
|[setZone] | `string` | `null` | no | Allows to set default zone on init. Example `America/Los_Angeles`. |

#### Outputs
| Output | Description |
Expand All @@ -77,6 +78,7 @@ export class AppModule { }
- [Roman Yanush](https://github.com/Romko775/)



----------------------

# Edit package
Expand Down
1 change: 1 addition & 0 deletions projects/moment-timezone-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class AppModule { }
| ------------- | ------------- | ------------- | ------------- | ------------- |
|[customPlaceholderText] | `string` | `Choose...` | no | Allows you to localize the placeholder text. |
|[getUserZone] | `boolean` | `false` | no | Allows you to guess user timezone. If `true` also emits value on init. |
|[setZone] | `string` | `null` | no | Allows to set default zone on init. Example `America/Los_Angeles`. |

#### Outputs
| Output | Description |
Expand Down
2 changes: 1 addition & 1 deletion projects/moment-timezone-picker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moment-timezone-picker",
"version": "0.2.1",
"version": "0.2.2",
"description": "A simple angular moment timezone picker",
"license": "MIT",
"author": "Roman Yanush",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ export class TZone {
})
export class MomentTimezonePickerComponent implements OnInit {

_setZone: string = null;
@Input('setZone')
set setZone(zone: string) {
if (zone && typeof zone === 'string' && zone.length > 0) {
this._setZone = zone;
} else {
this._setZone = null;
}
}

get setZone(): string {
return this._setZone;
}

@Input() customPlaceholderText = 'Choose...';
@Input() getUserZone = false;
@Output() onselect: EventEmitter<TZone> = new EventEmitter<TZone>();
Expand All @@ -45,7 +59,11 @@ export class MomentTimezonePickerComponent implements OnInit {
this.userZone = this.setObjectZone(momentZone.tz.guess(true));
this.emitChanges(this.userZone);
}
if (this.setZone) {
this.userZone = this.setObjectZone(this.setZone);
}
}

emitChanges(event: TZone) {
this.onselect.emit(event);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<ng-moment-timezone-picker (onselect)="log($event)" [getUserZone]="true">
<ng-moment-timezone-picker (onselect)="log($event)" [setZone]="'America/Los_Angeles'">

</ng-moment-timezone-picker>

0 comments on commit 6911fab

Please sign in to comment.