Open nmsan opened 7 years ago
Same for me.. https://codepen.io/Koutroupis/pen/MoZYKB
I still can't see what is the error. What are you trying to achieve?
I will close this issue in lack of description. If issue still presist, please provide steps to reproduce and I will reopen the issue.
I am trying to make a directive with your time picker. Whenever there is a change in the value I want to handle this change. I thought this would be possible if I add a function on the data-ng-change event but it's not triggered at all!
Thanks for your comment. ng-change is not yet supported. This should be added
Great news then! Any other way that I can programmatically be informed about the change in the date?
You could use $watch in $scope https://docs.angularjs.org/api/ng/type/$rootScope.Scope I would be carefull to use it, too many digests and you can end up with a slow performing application.
$scope.$watch('value', function() { // call something });
you also have a mdpTimePickerUpdated event emitted. I am planning to make a pull request for the ngChnage call is that ok with you ?
created a ng-change compatibility PR for this, hope this is ok with you ? Thank you for you lib !
Hi can u plz tell me, How can detect changes in time ?
@gaganpreets please check my fork you will have a ngChange parameter.
I am using following code , I didn't get any changes in dateChanges function. Please let me know if I am wrong.
<md-time-picker ng-model="model.endTime" ng-change="dateChanges($event)"
name="endTime"></md-time-picker>
$scope.dateChanges = function(event){
console.log("Date Changed")
console.log(event)
};
I used this pluggin some weeks ago for the simplicity of its interface (coupled with angular-moment for the date formatting inside template). And to watch any changes, as ng-change is not supported yet by the pluggin, I created a custom directive like so:
<md-time-picker
no-meridiem
ng-model="myDateStringModel"
name="myName"
watch-time-change="{{myDateStringModel | amDateFormat:'HH:mm'}}">
</md-time-picker>
angular
.module('myModule')
.directive('watchTimeChange', watchTimeChange);
function watchTimeChange($timeout) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
attrs.$observe('watchTimeChange', function(newTime) {
$timeout(function() {
//Use your newTime variable here
}, 0);
});
});
};
}
PS: the filter 'amDateFormat' is not mandatory, I just needed to display a Date in this format.
Hope this could help.
@gaganpreets my fork is there : https://github.com/sebius8780/angular-material-time-picker Good luck !
Could you please provide some more information about the issue?