click on apply event
Opened this issue · 7 comments
Hi
Is there a way to trigger event when user click on apply button after selecting dates?
I am wondering the same
ng-change works. I had some other issues on the code before...
autoApply exists in the base version. Should ideally be an option in this as well.
ng-change does not seem to work correctly, as it gets called twice every time you click Apply. Once when the value of the ng-model is a display string of the date range, and again when it is properly set to the moment.js date objects. Seems like there's possibly some race conditions going on with it as well...
Any Solution Yet, as i have to check for a date object every time.
+1
you can modify directive as per your requirements, basically you want to get default events in controller, i created solution, hope it would be useful
- Modify directive "ng-bs-daterangepicker.js", add events inside directive, as you want to add "apply.daterangepicker" event
$element.on("apply.daterangepicker", function(ev, picker) {
if($attributes.dpApply){
var invoker = $parse($attributes.dpApply);
invoker($scope, {event: ev, picker: picker});
}
});
and in view call directive
<input class="md-button" type="daterange" ng-model="dates4" ranges="ranges" opens="left" dp-apply="test(event, picker)"/>
in controller
angular.module('App').controller('CtrlName', function ($scope){
$scope.test = function(ev, picker){
console.log(ev, picker);
};
}):
you can also use other events as well, cheers!!!