Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo dropdown is empty in India #13

Open
chrgsoni07 opened this issue Nov 4, 2018 · 1 comment
Open

Demo dropdown is empty in India #13

chrgsoni07 opened this issue Nov 4, 2018 · 1 comment

Comments

@chrgsoni07
Copy link

I get the below error in console and the dropdown is empty

Asia/Calcutta
main.b3024e6c930273b7d557.bundle.js:1 ERROR TypeError: Cannot read property 'iso' of undefined
    at e.triggerChangeEvent (main.b3024e6c930273b7d557.bundle.js:1)
    at e.set [as timezone] (main.b3024e6c930273b7d557.bundle.js:1)
    at Li (main.b3024e6c930273b7d557.bundle.js:1)
    at main.b3024e6c930273b7d557.bundle.js:1
    at main.b3024e6c930273b7d557.bundle.js:1
    at Ki (main.b3024e6c930273b7d557.bundle.js:1)
    at La (main.b3024e6c930273b7d557.bundle.js:1)
    at Object.updateDirectives (main.b3024e6c930273b7d557.bundle.js:1)
    at Object.updateDirectives (main.b3024e6c930273b7d557.bundle.js:1)
    at $i (main.b3024e6c930273b7d557.bundle.js:1)```
@djorg83
Copy link

djorg83 commented Sep 17, 2019

Here is a workaround for the India problem. It sort of defeats the purpose of [guess]="true", but it works.

component.ts

import * as moment from "moment-timezone";

// flag to keep the timezone widget from rendering until we have initialized the event timezone.
initializedTimezone: boolean = false;

ngOnInit() {
  this.initTimezonePicker();
}

private initTimezonePicker() {
    const timezone: string = moment.tz.guess();
    if (timezone === 'Asia/Calcutta') {
      this.event.timezone = 'Asia/Kolkata';
    } else {
      this.event.timezone = timezone;
    }
    this.initializedTimezone = true;
  }

component.html

<!-- Timezone -->
<div *ngIf="initializedTimezone">
  <label>Time Zone</label>
  <ng2-timezone-picker
    [(timezone)]="event.timezone"
    [showOffset]="true"
    [guess]="true"
  ></ng2-timezone-picker>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants