Whichever Date i select, datepicker returns todays date. #1169

Closed
safiyu opened this Issue Oct 16, 2013 · 8 comments

Projects

None yet

5 participants

safiyu commented Oct 16, 2013

ngModel takes the value of todays date no matter whichever date i select. I used the exact way it is shown in the demo. But still such a problem.

Contributor

Can you provide a Plunk? That way we are able to check if it's really an angular-ui issue.

yannk commented Oct 16, 2013

That works with the following changes (passing selected date as a param to ok()):
http://plnkr.co/edit/WgpiuHLAsJamAyFMyrYN?p=preview

Obviously $scope in ModalCtrl is not what it seems to be. I can't explain why not though, it would be nice if someone more knowledgeable would chime in.

mini-me commented Oct 16, 2013

It seems that the truth is out there. First method works fine.

@mini-me yes, this is pure scoping issue. The modal directive uses transclusion (and thus creates intermediate a child, transclusion scope of a scope seen by a controller) in its directive responsible for window creation:
https://github.com/angular-ui/bootstrap/blob/master/template/modal/window.html

I know that those scoping issues are puzzling but using transclusion is the best I can think of for modal windows in order to avoid code repetition and make those windows felxible.

Closing as duplicate of #969

safiyu commented Oct 17, 2013

I got a simple solution for it. name ngModel something like dt.firstDate or dt.xyz . And initialize scope.dt = {};
Before i was using only dt as ngmodel. for multiple calendars i was using first,second and so on. Now everything Works fine. And thanks guys.

yannk commented Oct 18, 2013

For those reading @safiyu solution works probably like that:

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

safiyu commented Oct 19, 2013

Yeh exactly what I meant. Thanks Yannk. good to go.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment