Comments (9)
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.
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.
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.
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.
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.
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.
thank you @hexadecy! This works for me. It's closed.
from angular-material-datetimepicker.
@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.
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)
- min time and max time HOT 1
- Add mdDialog hasBackdrop option HOT 4
- Add am/pm text customization HOT 2
- Do you have this in a non-angular version? HOT 1
- Could not find a declaration HOT 1
- Setting shortTime=true on a date picker shows AM/PM indicator HOT 4
- Picker icons cause layout issues, show-icon enables too many options HOT 8
- Month displayed is not the same as month view HOT 5
- Upgrade angular library HOT 1
- Cannot set default values for all params of the directive. HOT 1
- Support clearing date from dialog HOT 2
- unable to load datetime picker on dialog box. HOT 5
- ng-change not being triggered as expected and validation failing HOT 5
- If ng-disabled is true. Input field is disabled but buttons are not HOT 4
- Date part is lost when editing time HOT 4
- Which Angular Version? HOT 1
- Option to edit both date and time at the same time on dialog? HOT 1
- Not compatible with Angular 1.8
- User cannot use blue bubble on the clock to set time on Firefox HOT 1
- Min/max date comparison is apparently not timezone-safe HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-material-datetimepicker.