fragaria / angular-daterangepicker

Angular.js wrapper for dangrossman/bootstrap-daterangepicker
MIT License
519 stars 372 forks source link

getting "Cannot set property 'date' of undefined" error #233

Closed narsignt closed 5 years ago

narsignt commented 7 years ago

Hi,

I am using bower to install packages. When i installed in my html file and i included directive like below

html file

js file var date = moment(), endDate=moment(date).endOf('week'), starDate=moment(endDate).subtract(2, 'months').startOf('week'), $scope.datePicker.date={startDate:starDate,endDate:endDate};

i am gettting below error

angular.js:13920TypeError: Cannot set property 'date' of undefined at new (calendarTableInput.html?_ijt=pg5hkgcscdp0f5opjipblpbolu:59) at Object.invoke (angular.js:4718) at S.instance (angular.js:10354) at p (angular.js:9263) at g (angular.js:8620) at angular.js:8500 at angular.js:1763 at m.$eval (angular.js:17682) at m.$apply (angular.js:17782) at angular.js:1761

Could anyone help on this.

Thanks, Narsi.

smnedelko commented 7 years ago

Hi, the $scope.datePicker obj is not exist, so instead of

$scope.datePicker.date={startDate:starDate,endDate:endDate};

use

$scope.datePicker = { date: {startDate:starDate,endDate:endDate} };