Save 3 days of your dev life — Date picker — Multi Field Validation — Angular.js $validators (working solution)

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

  1. You DO NOT want to use a regular date-picker — example
  2. You want to roll your own ☺
  3. You have fields that depend on other fields to be valid (multi-field)
  4. You want to save you ngModel — since $validators fails — ngModel becomes undefined

The Solution for undefined ngModel

See links below — and read them first

Explanation: Once the $validators pipeline fires — the ngModel = undefined, by design — see

So what can I do:

  1. Force values using JQuery — Nathan posted here
  2. Use $formatters & $pharsers directive — by andrezero
  3. Our method: Pass values back to scope once before $validators pipeline fires

Libraries used,,


Working Plunker

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 is cool — so check it out, it may solve this problem nicely.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.