Auto focus in ng-repeat in angularjs

前端 未结 4 1942
遇见更好的自我
遇见更好的自我 2021-01-17 19:04

I uses ng-repeat to get multiple phone numbers

4条回答
  •  無奈伤痛
    2021-01-17 19:32

    Having autofocus multiple times in your page is not forbidden, but does not look right based on the documentationm, https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input

    It saysOnly one form element in a document can have the autofocus attribute

    autofocus HTML5 This Boolean attribute lets you specify that a form control should have input focus when the page loads, unless the user overrides it, for example by typing in a different control. Only one form element in a document can have the autofocus attribute, which is a Boolean. It cannot be applied if the type attribute is set to hidden (that is, you cannot automatically set focus to a hidden control).

    I would not to use autofocus within ng-repeat and set focus manually after it is added.

提交回复
热议问题