Is it possible to monitor a date in angularJS? I have an ng-model that has a date and I would like to monitor it so that I receive a notification when it changes month, year, or day.
scope.$watch('ngModel',function(newVal){
console.log(newVal);
},true);
In my controller, I am passing a date object to a directive. Now, I want to monitor that date object.
module.directive('Datepicker',function(){
return {
restrict:'E',
scope:{
ngModel:"="
},
link: function(scope, element, attrs) {
//..other code here
scope.$watch('ngModel', function(newVal) {
console.log(ngModel);
}, true);
}
}
});