alenaksu / mdPickers

Material Design date/time pickers for Angular Material
MIT License
293 stars 216 forks source link

self.date is undefined #166

Open vidazoo-deployer opened 7 years ago

vidazoo-deployer commented 7 years ago

On mdPickers.js line 241 self.date.daysInMonth() is throwing an error. It seems like CalendarCtrl is not getting the values from datepicker (which is the alias of DatePickerCtrl). I could make it work by adding self.date = $scope.$parent.datepicker.date in CalendarCtrl.

versions: angular 1.6.0 angular-material 1.1.0 mdPickers 0.7.5 moment 2.17.1

LouisMazel commented 7 years ago

Sale versions, same issue...

andrea-vega commented 7 years ago

Same issue

andrea-vega commented 7 years ago

I believe the issue is a breaking change angular 1.6 made: "Disabling (by default) the pre-assignment of bindings on controller instances, which helps with support for native ES6 classes." https://docs.angularjs.org/guide/migration#migrate1.5to1.6-ng-services-$compile

All the logic that is currently in the constructor for the directive controllers needs to be moved into an $onInit function.

andrea-vega commented 7 years ago

https://github.com/alenaksu/mdPickers/pull/168 Fixes

danieloprado commented 7 years ago

same here

felipegouveiae commented 7 years ago

@danieloprado

I was able to temporary workarround installing the fork :

bower install -f --save https://github.com/andrea-vega/mdPickers.git#7c8f32fac12a01ad66e6728b603dcf8c7e86c0ce

@andrea-vega it worked like a charm. Thanks so much :)

andrea-vega commented 7 years ago

@felipegouveiae great! Glad to help :)

softsara commented 7 years ago

Great Thank you very much.

mcblum commented 7 years ago

Does anyone know if this fixes the time picker, too? I've got the following error:

TypeError: Cannot read property 'hours' of undefined
    at ClockCtrl.init (mdPickers.js:692)
    at new ClockCtrl (mdPickers.js:706)
    at Object.invoke (angular.js:5003)
    at $controllerInit (angular.js:10862)
    at nodeLinkFn (angular.js:9739)
    at compositeLinkFn (angular.js:9048)
    at publicLinkFn (angular.js:8913)
    at boundTranscludeFn (angular.js:9091)
    at Object.controllersBoundTransclude [as transclude] (angular.js:9858)
    at angular.js:31797

Line 692 is: self.selected = self.time.hours() || 0;

Edit: It appears this is all the same thing. Hoping for an accepted pull request!