fragaria / angular-daterangepicker

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

Struggling to get the selected date in controller after apply.daterangepicker event #87

Closed corientdev closed 5 years ago

corientdev commented 9 years ago

Struggling to get the selected start date and end date in controller after apply.daterangepicker event

vaesbart commented 9 years ago

I may be having a similar problem: I have to click "apply" twice before the model actually gets updated.

Vimos commented 9 years ago

Hope someone can offer a hint on how to fix this, "Click twice that model gets updated".

Vimos commented 9 years ago

Hi, it may be my fault. It finally works if I change the code to this:

    $scope.options = {
        eventHandlers: {
            'apply.daterangepicker': function (ev, picker) {
                var start = picker.startDate.format('YYYY-MM-DD');
                var end = picker.endDate.format('YYYY-MM-DD');
                $scope.drawChartTable(start, end);
            }
        }
    };

New date should be read from picker.

umdstu commented 8 years ago

On a related note, I get undefined for the 'picker' parameter when i click Apply. 'ev' is there but i need 'picker' obviously for the values, what could I be doing?

angular-datepicker.js version: master datepicker.js version: 2.1.13

ranieri82 commented 8 years ago

Any word on this...just opened an issue on picker being undefined. You are able to get to the values through ev.model.startDate and ev.model.endDate, however I'm trying to get the selected range parameter. For instance if a user selects the range "Yesterday" I want to know that

umdstu commented 8 years ago

I haven't made any discovories yet. Something in the angular code I suspect. I double checked the daterangerpicker.js listener and it sees the picker object.

umdstu commented 8 years ago

@Vimos can you provide your actual implementation of the picker? As in, is it using an or different tag, ie.

? What's the html/angular template code look like? Thanks!

mschaeuble commented 8 years ago

I think this issue can be closed in favor of https://github.com/fragaria/angular-daterangepicker/issues/119 See also my latest comment in there.