ng-model not registering input field change on datepicker selection

5,414 views
Skip to first unread message

finish...@yahoo.com

unread,
Jan 7, 2013, 2:01:55 PM1/7/13
to ang...@googlegroups.com
Before you say 'use the ui-date directive' - I am trying to achieve a datetime picker functionality (implementing a jquery datetime picker plugin).

Also, I have virtually no code, because I simply don't know where to start here...

Here's what the problem is: I can make a selection via the datetime picker (it's similar to the datepicker, but with two additional sliders - for the hour and minute). When the selection has been made, something like "2011/10/30 19:40" occupies the input but my model does not get updated. It only updates if I click on the input and do a backspace or something like that.

How do I make the directive register the event that marks a completed datetime selection?


Arsen.

Peter Bacon Darwin

unread,
Jan 7, 2013, 2:04:04 PM1/7/13
to ang...@googlegroups.com
There is little chance of help without any code.  If you can do what you are saying then you have enough code to provide a Plnkr.


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
 
 

finish...@yahoo.com

unread,
Jan 7, 2013, 2:11:56 PM1/7/13
to ang...@googlegroups.com
Well, can you just refer to my last sentence and try to answer that?

Since I am using jQuery and some plugins, it's a lot of work to set up the plunk (for me at least) and I think it's not a code problem at all, rather just my not knowing what to do.

Let's say I am trying something like

element.bind('change',function () {
   scope.$apply(function () {
     ngModel.$modelValue = element.value;
   });
  });

I think I have to use $apply, I am just not sure how.

So, to repeat the question again, "How do I make the directive register an external event?

If it's really necessary, a plunker will be provided later...

Arsen.

Peter Bacon Darwin

unread,
Jan 7, 2013, 2:20:10 PM1/7/13
to ang...@googlegroups.com
I don't think that getting irritable and using bold font is likely to improve your chances of getting help.  I am surprised that you seem to think that people on this list should spend their time deciphering your questions if you don't have the time to make your not working code available, yourself.

I still have no real idea what you problem is but from the tiny snippet you posted, you might like to try calling ngModel.$setViewValue rather than setting the $modelValue directly.  This is what the ui-date directive does and that code is freely available you to read: https://github.com/angular-ui/angular-ui/blob/master/modules/directives/date/date.js

If you need more help then a Plnkr or similar would be most useful.

Pete.

finish...@yahoo.com

unread,
Jan 7, 2013, 2:24:35 PM1/7/13
to ang...@googlegroups.com, finish...@yahoo.com
Hmm, I think I need to expand the onSelect event handler of the plugin (I see something like that is done in the ui-date directive code).

I'll be back later with my findings :)


Arsen.

finish...@yahoo.com

unread,
Jan 7, 2013, 2:31:04 PM1/7/13
to ang...@googlegroups.com
Oh no, I was not being irritable. Or not any more than usual hehe.

It's just that I implied that no plunker will be provided and you just went on and asked for it explicitly. Who is being irritable then? :D

As for my usage of bold font, I don't think it was inappropriate at all. Had I used caps, you'd have a point.

My impression was that it wasn't so hard to decipher, but point taken. A plunk is worth more than words, sometimes at least.

Though mind you I was just looking for a push in the right direction or an idea, not a working piece of code.

As for people on this group, they are of course not obligated to do anything, as far as I am concerned at least.

You in particular have been of great help to me in the past, but it seems today you just got up on the wrong foot or maybe need a break.

Anyway, like I said, I will try my idea and come back post my findings later.

Apologies for my lack of understanding for the importance of plunkers :)

No need to be agitated.

Arsen.

Michael Bielski

unread,
Jan 7, 2013, 2:44:02 PM1/7/13
to ang...@googlegroups.com, finish...@yahoo.com
Datepickers that are friendly with Angular:



Mayhap you should use one of those.
Reply all
Reply to author
Forward
0 new messages