1

I'm having an issue with $document.find, I need to scroll to a form error on submit.

var errors = $document.find('.input-name:not(.ng-hide)');

This is called when a form is submitted but has errors. On click it finds nothing, however if I click again a second later it has found the errors and I can scroll to it successfully. I believe it has something to do with watchers and the digest loop, but I've been messing with it for too long and thought I'd ask. Any help appreciated! Thanks

carrera
  • 185
  • 1
  • 10
  • 2
    sytax error: Should be $(document).find not $document.find – S M Nov 22 '16 at 11:55
  • to find an element in angular... see this one http://stackoverflow.com/questions/17283697/angularjs-how-to-find-using-jqlite – intekhab Nov 22 '16 at 12:02
  • That's worked perfectly. I had the same functionality working elsewhere, I had $document defined as a dependency, I must have got confiused, but that's great many thanks – carrera Nov 22 '16 at 12:03

1 Answers1

0

use this

and make sure to use $document in controller.

var errors = $(document).find('.input-name:not(.ng-hide)');