I have been working on a directive that has the following template (simplified):
<table>
<tr>
<td>
<input type="text"/>
</td>
<td>
<input type="text"/>
</td>
</tr>
</table>
Within the link function of the directive, I am trying to add listeners to the inputs but I'm having trouble accessing the input elements. Here is how the directive code looks:
angular.module('app').directive('myDirective', function(){
return{
restrict: 'E',
templateUrl: '<path-to-above-html-file>',
link: function(scope, element, attr){
var inputs = element.find('input'); // Returning empty JQLite object
}
};
});
Even though the Angular element documentation states that the find() method should be able to find nested elements, it's not functioning as expected in this case. Any insights into why this might not be working?
I've tried logging the element in the console and iterating through all child elements, confirming that the inputs do indeed exist.
Any assistance would be greatly appreciated!