如何将 angular 表达式变量传递给 ng-focus? ng-焦点="setFocus({{var}}"

How to pass an angular expression variable to ng-focus? ng-focus="setFocus({{var}}"

<tr data-ng-repeat="formGroup in formGroups  |  filter: {page: PAGE_current}">

<td>
    <input type="text" id={{formGroup.key}} name={{formGroup.name}}
           ng-focus="setFocus('{{formGroup.name}}')"
           minlength={{formGroup.min}} maxlength={{formGroup.max}}
           size={{formGroup.size}}/>
</td>
</tr>

setFocus 被调用,但 return 值为:所选字段无帮助:{{formGroup.name}}:undefined

控制台元素:

<input type="text" id="lastName" name="lastName"
       ng-focus="setFocus('lastName')"
       minlength="2" maxlength="20" size="50/">

无需使用 {{ }},即带事件绑定的字符串插值。 将值作为参数传递给函数时,直接使用 getter 和控件名称,无需插值。这给了 FormControl 然后使用 .value 来获取控件的当前值。

例如:setFocus(formGroup.get('name').value))

<td class="editInput">
   <input type="text" id="{{formGroup.name}}" name={{formGroup.name}}
          ng-focus="setFocus([formGroup.name])"
          required minlength={{formGroup.min}} maxlength={{formGroup.max}}
          size={{formGroup.size}}
          ng-model="editUser[formGroup.name]"/>
</td>

这个 post 回答了我的问题 52624566,对不起 angular 上的新手。