I have a directive which watches for change in an input field
directive('autocomplete', function(){
return {
link: function(scope, element, attrs){
scope.$watch(attrs.ngModel, function(){
console.log('change');
});
}
};
});
This works fine on the following element
<input type='text' ng-model='searchTerm' autocomplete>
But what if I was to put my directive on an ancestor element, like this:
<div autocomplete>
<input type='text' ng-model='searchTerm'>
</div>
How could I still watch the input for change then?