I have my form in $scope.myFormName which contains every NgModelController of every input field in there.
On error, I need to scroll to $invalid fields.
Thanks to this post I can access the list of the fields.
But now, I'd like to scroll up to the field. For this, I need to get the associated DOM element. So I do something like:
document.querySelector('name=['+inputName+']');
which feels dirty to me. Ain't there any pointer from the NgModel to its related DOM element? Or ain't this the angular way to do this?
document.querySelectorhad low browser compatibility, otherwise what is the point of still using jQuery? But apparently it is quite compatible ... caniuse.com/#feat=queryselectorangular.element. But I don't think that matters too much.