Giter Club home page Giter Club logo

Comments (9)

hexadecy avatar hexadecy commented on August 11, 2024 1

As a workaround, in your controller (inject $scope), then:

$scope.$watch(function() {
   return vm.valueModel;
}, function(newValue, oldValue) {
   // do something
});

ng-change normally does not evaluate the expression when the value change is coming from the model, in our case from the user keyboard.

from angular-material-datetimepicker.

hexadecy avatar hexadecy commented on August 11, 2024

ng-change is used on our production site since 25 Apr 2016.
I'm not sure what you try to do with vm.onChange? Why do you pass an object with a value that is already accessible anywhere in your current scope?

Try with:
<input mdc-datetime-picker ng-model="vm.valueModel" ng-change="vm.alert('changed')">

In your controller:

vm.alert = function(message) {
    window.alert(message);
    console.log(vm.valueModel);
};

from angular-material-datetimepicker.

hexadecy avatar hexadecy commented on August 11, 2024

I also added ng-clear="expression" in 1.9.7, because if the date value is cleared to undefined or not changed, ng-change does not trigger. ng-clear must be used with the X icon from show-icon=true.

from angular-material-datetimepicker.

jasondiazg avatar jasondiazg commented on August 11, 2024

The vm.onChange is a binding of the component that manage your input mdc-datetime-picker. If the programmer add the binding on-change, I invoke this from the ng-change method in the component. But do not pay attention to this at the moment.

Thank you for ng-clear! I will be testing this and I will tell you the results...

from angular-material-datetimepicker.

hexadecy avatar hexadecy commented on August 11, 2024

I found a bug, if the date is manually cleared (keyboard delete) when in edit-input="true", ng-change or ng-clear is not called.

Probably related to this check:

if (!moment(scope.currentDate).isSame(options.currentDate)) {       
    $timeout(scope.ngChange, 0);
}

from angular-material-datetimepicker.

jasondiazg avatar jasondiazg commented on August 11, 2024

Exactly that is the error that I have. The date is written directly by the user. Any idea for resolve this?

from angular-material-datetimepicker.

jasondiazg avatar jasondiazg commented on August 11, 2024

thank you @hexadecy! This works for me. It's closed.

from angular-material-datetimepicker.

hexadecy avatar hexadecy commented on August 11, 2024

@jasondiazg do you still use ng-clear?, I think I will call a ngChange on clear and also when the date go to undefined.

from angular-material-datetimepicker.

jasondiazg avatar jasondiazg commented on August 11, 2024

Go ahead, you can remove ng-clear if you wish! I'm not really using it. Thank you for your help.

from angular-material-datetimepicker.

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.