fragaria / angular-daterangepicker

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

correctly binds "this" and "arguments" to changeCallback #305

Closed divyun closed 5 years ago

divyun commented 5 years ago
el.daterangepicker angular.extend(opts, {autoUpdateInput: false}), (startDate, endDate, label) ->
  $scope.$apply () ->
    if (typeof opts.changeCallback == "function")
      opts.changeCallback.apply(this, arguments)

translates to

el.daterangepicker(angular.extend(opts, {
  autoUpdateInput: false
}), function(startDate, endDate, label) {
  return $scope.$apply(function() {
    if (typeof opts.changeCallback === "function") {
      return opts.changeCallback.apply(this, arguments);
    }
  });
});

The function there changes the scope of this and arguments

krtek commented 5 years ago

Thank you!