在ng-repeat中关注表格元素的tabindex

时间:2014-07-13 15:16:35

标签: html angularjs

我有一个包含列表元素的表,我希望能够使用箭头键跳过它。现在我必须先单击表格元素边框才能使用箭头键。如果我在循环中的一个元素上设置tabindex,它就不起作用。那么,如何在单击表格元素时将tabindex关注到它?

  <section ng-controller="PlaylistCtrl" >
      <table class="table table-striped table-hover " ng-keyup="keyPress($event.keyCode, $index)" tabindex="1">
        <thead>
          <tr>
            <th>
              <button  type="button" ng-click="toSubmit()"  class="btn btn-default">Add resource
              </button>
            </th>
          </tr>
        </thead>
        <tbody ui-sortable ng-model="result">
          <tr ng-repeat="resource in result">
            <td ng-class="isSelected(resource)">
              <div ng-click="showResource(resource, $index)">
                {{resource.name}}
              </div>
            </td>
            <td ng-class="isSelected(resource)" style="width: 15px;"><span class="glyphicon glyphicon-remove" id="sidebarEdit" ng-click="removeResource(resource, $index)"></span></td>
          </tr>
        </tbody>
      </table>
  </section>

1 个答案:

答案 0 :(得分:2)

document.getElementById('table_id').focus();

相关问题