1
Good night.
I’m wearing a directive
for a datepicker
and I’m getting the following error.
TypeError: Cannot read property 'split' of undefined
at Object.DPGlobal.parseDate (http://localhost:8080/ltfinaceira/assets/js/bootstrap-datepicker.js:393:20)
at Datepicker.update (http://localhost:8080/ltfinaceira/assets/js/bootstrap-datepicker.js:161:25)
at new Datepicker (http://localhost:8080/ltfinaceira/assets/js/bootstrap-datepicker.js:84:8)
at HTMLDivElement.<anonymous> (http://localhost:8080/ltfinaceira/assets/js/bootstrap-datepicker.js:341:38)
at Function.m.extend.each (http://localhost:8080/ltfinaceira/js/Jquery/jquery.min.js:2:2975)
at m.fn.m.each (http://localhost:8080/ltfinaceira/js/Jquery/jquery.min.js:2:835)
at $.fn.datepicker (http://localhost:8080/ltfinaceira/assets/js/bootstrap-datepicker.js:336:15)
at link (http://localhost:8080/ltfinaceira/js/Directive/datepickerDirective.js:6:20)
at invokeLinkFn (http://localhost:8080/ltfinaceira/lib/angular/angular.js:8746:9)
at nodeLinkFn (http://localhost:8080/ltfinaceira/lib/angular/angular.js:8246:11) <div ng-switch="datepickerMode" role="application" ng-keydown="keydown($event)" type="text" class="form-control ng-isolate-scope" ng-model="data" datepicker="">
DIRECTIVE
angular.module('app').directive('datepicker', function() {
return {
// restrict: 'A',
require : 'ngModel',
link: function(scope, element, attrs, ngModelCtrl) {
$(element).datepicker({
dateFormat:'dd-mm-yyyy',
language: 'pt-BR',
pickTime: false,
startDate: '01-11-2013', // set a minimum date
endDate: '01-11-2030' // set a maximum date
}).on('changeDate', function(e) {
ngModelCtrl.$setViewValue(e.date.toLocaleDateString());
scope.$apply();
});
}
};
});
Hard to know just by seeing the details of the exception you posted here, try debugging in firebug
– fabiohbarbosa