ng2-ui / datetime-picker

Angular2 DateTime Picker
https://ng2-ui.github.io/#/datetime-picker
MIT License
121 stars 62 forks source link

angular 2 final intergration? #37

Closed mickeychu closed 7 years ago

mickeychu commented 7 years ago

How to make this work with Angular 2 final (2.0.1) ? thank you!

allenhwkim commented 7 years ago

It's already 2.0 ready. README.md install instruction does not work with 2.0?

mickeychu commented 7 years ago

It works, but it caused this warning:

screen shot 2016-09-27 at 16 26 39

Besides, it made my form always Dirty from the beginning, even I have set it to Pristine.

If I removed the datetime-picker directive, no warning and the form become pristine as normal when the page first loaded.

here's the HTML

<input type="text" formControlName="deadlineDate" [(ngModel)]="myForm.value.deadlineDate" ng2-datetime-picker close-on-select="false" date-only="true" (blur)="myForm.markAsDirty()">

PS: I'm using Angular 2.0.1

allenhwkim commented 7 years ago

Thanks for reporting this. I will treat as bug.

allenhwkim commented 7 years ago

@Krisa can you look into this issue?

0cv commented 7 years ago

@mickeychu - the latest PR shall have resolved that.

But you should remove blur and ngModel because I think there is some conflicts here.

<input type="text" formControlName="deadlineDate" ng2-datetime-picker close-on-select="false" date-only="true">

@allenhwkim I think the Readme is slightly outdated too in this regard (it references both ngModel and formControl)

allenhwkim commented 7 years ago

https://plnkr.co/edit/su2aiL?p=preview image

I have tested this plunker without ngModel, but it seems never makes the form dirty by selecting a date. With ngModel, it makes form dirty initially. In either case, it's not desirable behaviour, I think.

0cv commented 7 years ago

This works when clicking on a link, but selecting a date is not triggering the markAsDirty method ... will check later today

allenhwkim commented 7 years ago

thanks @Krisa

0cv commented 7 years ago

there is something weird with all these messages. but the PR looks normal.

mickeychu commented 7 years ago

I've updated the package to latest release 0.9.5. Removed the ngModel. The form is not Dirty when the page first loaded.

However, when I change the date and submit the form, the value of the date does not change at all. (though it does change the date displayed on the input)

Tested it with :

            this.myForm.controls['start_date'].valueChanges.subscribe(data => {
                    console.log(data);
            });

Nothing happened.

0cv commented 7 years ago

Yes, the package has not been updated on Npm yet. Can you try with the github version instead?

mickeychu commented 7 years ago

Oh yes, it works perfect now. Thank you @Krisa . Will you update the npm package soon?

0cv commented 7 years ago

@allenhwkim is the Npm master!

allenhwkim commented 7 years ago

This should be on npm. 0.9.6 matches to the current github master branch.