2

I am trying to integrate ng2-datepicker in my project.

It worked fine until I tried to use the options. According to the documentation, I can pass options to the component using property bindings. So I tried to customize the format :

<ng2-datepicker [(ngModel)]="date" viewFormat="DD-MM-YYYY" name="date"></ng2-datepicker>

But the date is still displayed in the wrong format (and which is not the one that is supposed to be the default format according to the documentation).

I also tried to open the calendar by default with the option opened and it also did not work.

I looked at the referenced issues on github and none mentions this problem which is yet obvious. That makes me think that I misunderstood something.

Any ideas?

4

3 に答える 3

5

ドキュメントが最新ではありませんでした。これで、"options" 属性を使用してオプションを渡すことができます。

mycomponent.html:

<ng2-datepicker [(ngModel)]="date" name="date" [options]="calendarOptions"></ng2-datepicker>

mycomponent.ts:

export class MyComponent implements OnInit {
  calendarOptions = {
    format: "DD-MM-YYYY",
    firstWeekdaySunday: false
  };
于 2016-12-19T21:27:43.680 に答える