luisfarzati / ng-bs-daterangepicker

AngularJS directive for bootstrap-daterangepicker
http://luisfarzati.github.io/ng-bs-daterangepicker/
MIT License
246 stars 167 forks source link

Default date range not working. #122

Open raalveco opened 8 years ago

raalveco commented 8 years ago

I have implemented the library, but I have a problem to set the default date range when I try to set the default for the current month range, in my controller I have this:

$scope.filters = { company_id: 0, service_type_id: 0, status: 0, dates: { startDate: moment().startOf('month'), endDate: moment().endOf('month') } };

In my view I have the following code:

<input type="daterange" ng-model="filters.dates" ranges="ranges" locale="locale" ng-change="changeRange()"/>

Image Example: http://prntscr.com/c27e9q

If I define a similar variable, but do not put in the ng-model of input, variable prints correctly with the values defined in the controller, but when used in the ngmodel, this is changed by a range that only contemplates the day from today.

$scope.filters = { company_id: 0, service_type_id: 0, status: 0, dates: { startDate: moment().startOf('month'), endDate: moment().endOf('month') }, another_dates: { startDate: moment().startOf('month'), endDate: moment().endOf('month') } };

{{filters.another_dates}}<input type="daterange" ng-model="filters.dates" ranges="ranges" locale="locale" ng-change="changeRange()"/>

Image Example: http://prntscr.com/c27gy6

For some reason the ng-model resets the variable scope and assigns a default value different than I had defined.

I would also like to know if there is a way to define an empty value and not pre-load by default today's date.

navsaini53 commented 8 years ago

same issue

vikash-zeotap commented 8 years ago

I also have same issue. Unable to set any date as default value. Always show today's date.

OldrichKruchna commented 8 years ago

+1

tompie87 commented 7 years ago

+1,

You can change te following values for the default view. I have put at least a day between them... this works.

image

pavanshinde47 commented 7 years ago

having same issue.. anyone got some solution?

rohitsharma2522 commented 7 years ago

same issue. Not able to set default date

d4guru commented 6 years ago

I have the same issue, the problem is the directive doesn't work when the startDate and endDate is the "child" of a Javascript Object.

If you set the date this way it works.

$scope.myDates = { startDate: moment('05/10/2015'), endDate: moment('10/10/2016') };

But if you set the date this way it doesn't work

$scope.data = { somepropertie : "joe", myDates : { startDate: moment('05/10/2015'), endDate: moment('10/10/2016') } }