I think because elm is an object that's defined by angular (not sure why), and elm[0] is an actual DOMElement, so it has focus() method.
On Thursday, March 20, 2014 3:42:36 AM UTC+7, Elliott Regan wrote: > > Do you know why I needed to user elm[0].focus() instead of just > elm.focus() as it is in your fiddle? > > When I used elm.focus() on my local setup, I got a "Type undefined: > elm.focus is not a function" error. (angular 1.2.14, current browsers) > > On Sunday, May 20, 2012 10:43:09 PM UTC-4, Vojta Jína wrote: >> >> How about this http://jsfiddle.net/vojtajina/nycgX/ ? >> >> V. >> >> On Thu, May 10, 2012 at 7:44 AM, bkc <[email protected]> wrote: >> > I have a form that uses ng-repeat with orderBy >> > >> > When a user clicks 'add' my controller pushes a mapping into an array >> and >> > ng-repeat updates the html. Very nice. >> > >> > From a usability standpoint, it would be helpful to the user to focus >> on one >> > of the newly added input elements. >> > >> > What is the best way to accomplish this? >> > >> > 1. Have to know when the html has been updated >> > >> > 2. need to figure out how to determine the html element that >> corresponds to >> > the javascript array item >> > >> > 3. I could associate a directive with the input element(s), but the add >> > button is outside of ng-repeat, how do I broadcast an event into the >> correct >> > ng-repeat scope so the correct directive is activated? >> > >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "AngularJS" group. >> > To view this discussion on the web visit >> > https://groups.google.com/d/msg/angular/-/0ScMzS7wCfMJ. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]. >> > For more options, visit this group at >> > http://groups.google.com/group/angular?hl=en. >> > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
