Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function bindRange(scope, el, attrs){
var getFrom = $parse(attrs.pickFrom);
var setFrom = getFrom.assign;
var getTo = $parse(attrs.pickTo);
var setTo = getTo.assign;
var time = hasTime(attrs);
function updateField(){
var from = getFrom(scope);
var to = getTo(scope);
el.val(dateParsing[time ? "formatRangeWithTime" : "formatRange"](from, to));
}
scope.$watch(getFrom, updateField);
scope.$watch(getTo, updateField);
el.on('keyup', function(){
var parseMethod = time ? "parseRangeWithTime" : "parseRange";
var parsed = dateParsing[parseMethod](getFrom(scope), getTo(scope), el.val());
setFrom(scope, parsed.from);
setTo(scope, parsed.to);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.