I have a directive in which I want to find <input/>
and <select>
elements to bind a blur
event to them. I know I this could be done with ng-blur
but this question is really about the angular.element
selector.
link: function(scope, elem, attrs){
elem.find( 'input, select' ).bind( 'blur', someFunction); // doesn't work as input, select returns length 0
// this works when separated
elem.find( 'input' ).bind( 'blur', someFunction);
elem.find( 'select' ).bind( 'blur', someFunction);
}
I guess the question is why doesn't the first way work?
the documentation states:
find() - Limited to lookups by tag name from https://docs.angularjs.org/api/ng/function/angular.element
but doesn't say that it's limited to single tag lookups. Am I doing something wrong? Did I miss some documentation somewhere?