luisfarzati/ng-bs-daterangepicker

Default date range not working.

Opened this issue · 7 comments

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.

same issue

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

+1,

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

image

having same issue.. anyone got some solution?

same issue. Not able to set default date

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')
}
}