1
votes

Can anyone help me in creating a Angular-js Directive that can handle three field date,

I need a directive for the solution specified in the below link,

http://plnkr.co/edit/lHffXV7xEda0xYorucMe?p=preview

I tried out a couple of solutions and was not rendering properly.

Any plunker illustration would also help. A plunker link is specified below,

http://plnkr.co/edit/lHffXV7xEda0xYorucMe?p=preview

1
If all that you need is html template to be stored as different file so here is directive:plnkr.co/edit/sia1HAGB8aIytPVD7Juy?p=preview - happyZZR1400
Many Thanks - How will the ng-model binding with the back end JSON Obejct will work in this scenario. - Harry
I require to reuse the same date in other places, Is this a standard to use it in this way ? - Harry
Can any one help, I need to pass ng-modiel for three date boxes. - Harry
I didnt quite understand, what the problem you trying to solve: in your example you already have three inputs each attached to some ng-model, what you want to be different? - happyZZR1400

1 Answers

1
votes

See ngModelController for an example how to implement a custom directive with ng-model support. I have created a simple implementation based on this example, you can see demo here.

My current implementation has one drawback - it does not handle invalid dates correctly. To fix this you could either make sure that user cannot enter invalid date or add validation support to the directive via $formatters and $parsers of ngModelController. I guess the latter would not be difficult, if I have time I'll try to do that later.