Giter Club home page Giter Club logo

Comments (8)

mortenholmgaard avatar mortenholmgaard commented on July 27, 2024 1

I have found a way to fix this:

In Module.directive('dateTime' ...) link method:
element.bind("change", function (e) { //Custom method
console.log("Input changed");
var newDate = parseDate(e.srcElement.value, e.srcElement.attributes["format"].value);
scope.$broadcast('set-user-typed-date', { date: newDate });
clear();
});

This code to parse any date format:
function parseDate(input, format) { // http://karpcom.blogspot.dk/2011/02/constructing-javascript-date-object.html
format = format || 'dd/MM/yyyy'; // somedefault format
var parts = input.match(/(\d+)/g),
i = 0, fmt = {};
// extract date-part indexes from the format
format.replace(/(yyyy|dd|MM)/g, function (part) { fmt[part] = i++; });
return new Date(parts[fmt['yyyy']], parts[fmt['MM']] - 1, parts[fmt['dd']]);
}

And this in Module.directive('datePicker' ...) link method:
scope.$on('set-user-typed-date', function (event, args) {//Custom code
scope.setDate(args.date);
});

from angular-datepicker.

mortenholmgaard avatar mortenholmgaard commented on July 27, 2024

I have the same problem..

from angular-datepicker.

dam1 avatar dam1 commented on July 27, 2024

set the value with "new Date()" not a String

from angular-datepicker.

flyawaychen avatar flyawaychen commented on July 27, 2024

I have tried mortenholmgaard's method, but on the ngModel, only the view value is changed, the modelValue is still not changed :(

from angular-datepicker.

eralha avatar eralha commented on July 27, 2024

flyawaychen send a plunker with example code please.

from angular-datepicker.

rjurado01 avatar rjurado01 commented on July 27, 2024

@yelnar +1 http://plnkr.co/edit/JEe8jb?p=preview

When I insert/change date by input (using keyboard) ng-model value is not updated.

from angular-datepicker.

SimonKlausLudwig avatar SimonKlausLudwig commented on July 27, 2024

@rjurado01
i changed this: parseDate(e.srcElement.value, e.srcElement.attributes["format"].value);
to this: parseDate(e.originalEvent.srcElement.value, e.originalEvent.srcElement.attributes["format"].value);

and finally i do this:

var format = "yyyy-MM-dd";
var newDate = parseDate(e.originalEvent.srcElement.value, format);

and i have to do this:

scope.$apply();

from angular-datepicker.

knvpk avatar knvpk commented on July 27, 2024

This is very annoying , when editing the fields. @mortenholmgaard thanks for fix.

from angular-datepicker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.