Live, Realtime 3 Ways Data-binding Date-time Input On Angularfire
I have the following simplified version of my code: tr(ng-repeat='entry in ds3.entries | orderBy:orderByField:reverseSort | filter:query as results') td input.scr
Solution 1:
Putting this on your <input type="date" date-conversion/>
will handle 3 way binding with AngularFire and dates.
app.directive('dateConversion', function () {
return {
restrict: "A",
require: "ngModel",
link(scope, element, attributes, ngModel) {
ngModel.$formatters.push(value => {
let output = null;
if (value) {
scope.stringValue = value;
}
if (value) { output = moment(value).toDate(); }
return output;
});
ngModel.$parsers.push(value => {
let output = null;
if (value) { output = moment(value).format(); }
return output;
});
},
}
});
Post a Comment for "Live, Realtime 3 Ways Data-binding Date-time Input On Angularfire"