Giter Club home page Giter Club logo

Comments (5)

djmarcus1 avatar djmarcus1 commented on September 23, 2024

Turns out the problem was in what I put in my controller's scope.

These 2 lines worked:

$scope.minDate = new Date();

However when I replaced the above with simply tomorrow's date (at time of posting the local date is July 9, 2015):

$scope.minDate = new Date(2015, 7 - 1, 10);

I get these two errors:

TypeError: scope.minDate.clone is not a function
at optimize (quantumui.js:2780)
at Object.angular.module.run.provider.$get.$picker.init (quantumui.js:2519)
at quantumui.js:4277
at processQueue (angular.js:14551)
at angular.js:14567
at Scope.$get.Scope.$eval (angular.js:15830)
at Scope.$get.Scope.$digest (angular.js:15641)
at Scope.$get.Scope.$apply (angular.js:15935)
at bootstrapApply (angular.js:1624)
at Object.invoke (angular.js:4443)

(anonymous function) @ angular.js:12314
$get @  angular.js:9101
processQueue @ angular.js:14559
(anonymous function) @ angular.js:14567
$get.Scope.$eval @ angular.js:15830
$get.Scope.$digest @ angular.js:15641
$get.Scope.$apply @ angular.js:15935
bootstrapApply @ angular.js:1624
invoke @ angular.js:4443
doBootstrap @ angular.js:1622
bootstrap @ angular.js:1642
angularInit @ angular.js:1536
(anonymous function) @ angular.js:28289
jQuery.Callbacks.fire @ jquery.js:3148
jQuery.Callbacks.self.fireWith @ jquery.js:3260
jQuery.extend.ready @ jquery.js:3472
completed @ jquery.js:3503


TypeError: Cannot read property 'clone' of undefined
at quantumui.js:3070
at apply (quantumui.js:3176)
at Object.fn (quantumui.js:3069)
at Scope.$get.Scope.$digest (angular.js:15667)
at Scope.$get.Scope.$apply (angular.js:15935)
at bootstrapApply (angular.js:1624)
at Object.invoke (angular.js:4443)
at doBootstrap (angular.js:1622)
at bootstrap (angular.js:1642)
at angularInit (angular.js:1536)

Apparently, setting the scope variable of minDate to a value that is NOT today causes this error.

*This appears to be a bug in the datepicker *

from quantumui.

mehmetotkun avatar mehmetotkun commented on September 23, 2024

You must use moment instead of Date object; here is moment documentation

from quantumui.

djmarcus1 avatar djmarcus1 commented on September 23, 2024

Understood... thanks for the clarification.

My suggestion is the datepicker should detect that Date is used and silently convert to moment. This would allow the users to have the flexibility of using either format. I absentmindedly used Date because the documentation didn't say we had to (while it does say you need moment.js for datepicker, it does not say that all dates for the datepicker have to be moment objects).

However, the real problem (bug?) is why is the datepicker even looking at my $scope.minDate?

If it is using it as a 'master' setting for all datepickers then it should be using the 'config' mechanism. Nowhere in the documentation do I see a mention that the $scope.minDate is used by the datepicker.

Otherwise, how would I be able to set the min date separately for each datepicker ?

-David

from quantumui.

mehmetotkun avatar mehmetotkun commented on September 23, 2024

Hi David,

Thank you for your clear suggestion.

I found the reason. Currently, we detect string, when setted as optioin. Beacuse when it setted as object(Date or moment) it required to cloned. I will update it in next release.

Also, $datepickerProvider has already config mechanism and each picker has own options.

from quantumui.

mehmetotkun avatar mehmetotkun commented on September 23, 2024

Currently you have two alternative to resolve your case;

  1. Set minDate as string:

$scope.minData = moment().format('yourformat')

  1. Change the source code:

replace this line

scope.minDate = moment(options.minDate, options.format);

with

scope.minDate = angular.isString(options.minDate) ? moment(options.minDate, options.format) : angular.isDate(options.minDate) ? moment(options.minDate) : moment.isMoment(options.minDate) ? options.minDate.clone():moment();

Also it should be updated for maxDate and startDate too.

from quantumui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.