-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Unable to use init-date attribute #2331
Comments
Hello, I have no idea how to work with datepicker options or datepickerConfig. https://github.com/wleelavivat/bootstrap/commit/4fda36a1df69a043b07c8c8f8733144d73f9c79e The problem is that the init-date attribute in a datepicker element never gets registered in the attribute set of datepickerController, so reverting the change fixes it. You need to map a Date object to init-date. I tested it on AngularJS 1.2.10, Angular-UI 0.11.0. |
Hi, I have the same problem. I have found out, that init-date should be provided only as an datepickerConfig property, because DatepickerController does not see it, if init-date is provided inline. but this string throws an exception:
seems that $scope.$parent.$eval($attrs.initDate) should return a Date obj, but it does not.
Can someone please provide an example of using init-date. |
http://plnkr.co/ijDYzZc9R3Fxw4jTlz46 |
After trying the code of @sl45sms which worked as he said, I tried to implement it with a popup, and as you can see here http://plnkr.co/yq7OrO8ZecpE7RvwTqvM it doesn't work ! I used the same versions as @sl45sms. |
I have done a pull request to correct that issue : #2438. |
I am also experiencing this problem, what can we do to get this merged? |
👍 |
2 similar comments
+1 |
👍 |
Got it working too by passing the datepicker-options Still, I realised the expression was not being watched, which renders it useless in the use case of a from/to pair of datepickers... |
I have been looking into this have made the following determinations which I think satisfy the needed investigation. I would like @chrisirhc to evaluate my conclusions if he has time and if he concurs, I have a fix in place locally that I can submit as a pull request w/o too much effort. Per the documentation the init-date attribute should work either as its own attribute, or as a value in datepicker-options. As sl45sms demonstrated, init-date works on the datepicker. However it does not work on the datepicker-popup, neither directly nor as part of datepicker-options. Here is why: In the case of datepicker-options, the problem is that the value is being $evaled twice, once on [line 475](https://github.com/angular-ui/bootstrap/blob/master/src/datepicker/datepicker.js#L475 - 76) and a second time on line 47. This I believe is why redben got things working by using glitches around his 'path.to.variable' and why he needed to prefix it with $parent.$parent. The first $eval removed the glitches effectively set In the case of applying the init-date attribute directly to the datepicker-popup, the code to handle this is simply missing. It is this case that Thomas W is addressing with pull-request #2438. Line 47 clearly needs to perform an $eval in order to keep the basic case working which sl45sms demonstrated. Therefore it seems the solution for larger issue it to incorporate into the existing pull request a modification to line 475 to handle things differently for the datepicker-options scenario. However this only gets us to the point of initially setting the init-date correctly. I believe I now have working code that supports also changing the initdate on the fly to support the from/to case that someone mentioned. The need to support that case is how I got to looking into this to begin with. Comments? |
+1 for setting |
I have submitted pull request #2972 which I believe addresses all of the issues discussed herein, including that fact that init-date is not watched after initial evaluation. |
hi @kbaltrinic, for me your solution works in my project, so I'm afraid that until your pull request will be accepted, I'm gonna to put direct your changes into my file and load the datepicker from local instead of bower. Sorry :( Thanks. |
@felixzapata UPDATE: It would be great if this pull was added to master!!! |
for my case, this way:
|
not only this pull request @trickpattyFH20 would be great ;) , I would need another pull request that it was sent a few months ago about the navigation. |
+1 |
Please accept #2438 made like a hundred years ago! |
Please be just a little more patient. We're actively going through all PRs at the moment. |
This is truly fixed by 98e2bdf. |
Hey all,
I'm unable to get the init-date working as an attribute set for the datepicker, does anyone have any examples I can pull to see where it's working? I was looking at the demo but for whatever reason this commit removed the only reference to the initDate in the Javascript:
#2184
I copied the plunker on the demo page and tried to edit it:
http://plnkr.co/edit/ZGz7rmv09p6SFVVGB9VX?p=preview
I tried sticking it in the datepicker options as initDate: $scope.initDate
and I also tried to just define init-date: initDate on the attributes of the datepicker.
I've browsed through as many issues as I could and Google didn't have an example as the init-date is pretty new.
Thanks for your help!
The text was updated successfully, but these errors were encountered: