Decouple directive input value from model

40 views
Skip to first unread message

Sébastien Saunier

unread,
Feb 10, 2014, 2:20:49 AM2/10/14
to ang...@googlegroups.com
Hello guys,

I am trying to wrap the fondation-bootstrap datepicker into a directive and I have some trouble watching for an update in my controller. I get two notifications, one with a Date object, and one with the string value of the input (which I don't want).

I asked my question on SO: http://stackoverflow.com/questions/21660774/creating-a-directive-for-a-datepicker-watching-model-triggers-two-updates

Any help much appreciated!

Thanks.

Sander Elias

unread,
Feb 10, 2014, 3:03:28 AM2/10/14
to ang...@googlegroups.com
HI Sébastien,

I think you need a parser/formatter for this. If you build a plunk/fiddle, more of us are willing to take a look at it.

Regards
Sander

Sébastien Saunier

unread,
Feb 10, 2014, 3:20:32 AM2/10/14
to ang...@googlegroups.com
Hello Sander,

Thanks for the hint, I will investigate both and come at you with some code to play with.

-- 
Sébastien Saunier

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/dsd0lU8WLdc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Stephen Friedrich

unread,
Feb 10, 2014, 9:27:18 AM2/10/14
to ang...@googlegroups.com
In my experience you can avoid trouble by encapsulating the input tag, rather than re-using it, so you might try

<div fdatepicker>

and then let the directive's template add the input inside the div.
That way your directive's ngModel is separate from the input's ngModel.
Reply all
Reply to author
Forward
0 new messages