JohannesHoppe / angular-date-value-accessor

Home of the Angular DateValueAccessor for <input type="date">
http://johanneshoppe.github.io/angular-date-value-accessor/
MIT License
78 stars 19 forks source link

append config when use SystemJS and error #8

Closed hhntpp closed 4 years ago

hhntpp commented 7 years ago

I used SystemJS to load files. It had error: Failed to load resource: the server responded with a status of 404 (Not Found) /angular-date-value-accessor I found the solution: add config to file systemjs.config.js. You should change the help config for this case.

My template used: <input type="date" [(ngModel)]="user.Birthday" useValueAsDate> with datatype of Birthday: Date; It could run with no error (console log no error, and I had set user.Birthday = new Date() in constructor ), when I set user.Birthday = new Date() in a click event button, and console log of Chrome had multi errors: Uncaught (in promise): TypeError: Failed to set the 'valueAsDate' property on 'HTMLInputElement': The provided value is not a Date. TypeError: Failed to set the 'valueAsDate' property on 'HTMLInputElement': The provided value is not a Date. at DomRenderer.setElementProperty (node_modules/@angular/platform-browser/bundles/platform-browser.umd.js:3070:45) at DateValueAccessor.writeValue (node_modules/angular-date-value-accessor/date-value-accessor.js:27:24) ...

Although it thrown error, the value of user.Birthday still got the date from input control and vice versus.

I found your date-accessor from http://stackoverflow.com/questions/37055311/angular2-how-to-use-javascript-date-object-with-ngmodel-two-way-binding I tried some solutions in that post, they had problems when inputted value of year by keypress. Your solution doesn't have that problem. I hope you check your project and fix this error.

JohannesHoppe commented 7 years ago

Let me separate this into 2 issues:

  1. configuration of your module-loader. I'm up to enhancements to the README, or any other new file. Please send a PR.
  2. The provided value is not a Date you used types of Date? Are you sure? If yes, please provide a plunkr / jsfiddle so that I investigate.
hhntpp commented 7 years ago

I'm sorry for I could not provide plunkr/jsfiddle, because I don't know how to attach your date-value-accessor to plunkr/jsfiddle.

JohannesHoppe commented 7 years ago

Sorry, I can't help with that. My time is rare right now!

vmaldosan commented 7 years ago

Getting same 404 error. @hhntpp what did you add to systemjs.config.js?