Friday, 27 September 2013

undefined scope into $watch

undefined scope into $watch

I have a directive named dir with:
ng-model="job.start_date"
comparison-date="job.end_date
Into scope.$watch("comparisonDate... I want to access my ng-model value.
The problem is that scope is undefined into watch's callback function. The
Question is: How can I get the ng-value inside this function?
.directive("dir", function() {
return {
scope: {
comparisonDate: "=",
ngModel: "="
},
link: function (scope, element, attrs, ctrl) {
scope.$watch("comparisonDate", function(value, oldValue) {
console.log(value);
console.log(scope.ngModel);
})
}
};
})
the view...
<input dir type="text" ng-model="job.start_date"
comparison-date="job.end_date"/>

No comments:

Post a Comment