Date Picker — If all you want is to add date picker to your app — get it here ☺
Invalid State — Multi-field
Valid State — Multi-field
Working Date picker here — Plunker
The Problem
- You DO NOT want to use a regular date-picker — example
- You want to roll your own ☺
- You have fields that depend on other fields to be valid (multi-field)
- You want to save you ngModel — since $validators fails — ngModel becomes undefined https://github.com/angular/angular.js/issues/1412
The Solution for undefined ngModel
See links below — and read them first
Explanation: Once the $validators pipeline fires — the ngModel = undefined, by design — see https://github.com/angular/angular.js/issues/1412
So what can I do:
- Force values using JQuery — Nathan posted here
- Use $formatters & $pharsers directive — by andrezero
- Our method: Pass values back to scope once before $validators pipeline fires
Libraries used
http://momentjs.com/, https://angularjs.org, https://docs.angularjs.org/api/ngMessages/directive/ngMessages
Solution
If this was helpful, leave a comment and I will create a quick video and walk you through the solution. Otherwise, best have fun with multi-validation. I also heard that https://github.com/formly-js/angular-formly is cool — so check it out, it may solve this problem nicely.