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?