Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Implementing a custom 'moment' on 'options' definition
  • Loading branch information
paulodrade committed Jan 11, 2019
commit cb7b8cc14c0dc6c91a231f3ebc3286c35600abaf
5 changes: 3 additions & 2 deletions coffee/angular-daterangepicker.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pickerModule = angular.module('daterangepicker', [])

pickerModule.constant('dateRangePickerConfig',
cancelOnOutsideClick: true
moment: window.moment
locale:
separator: ' - '
format: 'YYYY-MM-DD'
Expand Down Expand Up @@ -68,7 +69,7 @@ pickerModule.directive 'dateRangePicker', ($compile, $timeout, $parse, dateRange

_setDatePoint = (setter) ->
(newValue) ->
if (newValue && (!moment.isMoment(newValue) || newValue.isValid()))
if (newValue && (!opts.moment.isMoment(newValue) || newValue.isValid()))
newValue = moment(newValue)
else
# keep previous value if invalid
Expand Down Expand Up @@ -102,7 +103,7 @@ pickerModule.directive 'dateRangePicker', ($compile, $timeout, $parse, dateRange

getViewValue =(model) ->
f = (date) ->
if not moment.isMoment(date)
if not opts.moment.isMoment(date)
then moment(date).format(opts.locale.format)
else date.format(opts.locale.format)

Expand Down