Angular X-editable 设置焦点事件

Angular X-editable set focus event

我正在使用 angular-xeditable api.Could 你告诉我如何在形成 'loads' 并按下 'add row' 按钮时将焦点设置到控件中?

JsFiddle

上面api.But上面有个方法叫$activate(name),上面scenarios.Thanks不知道怎么用。

 // add user
  $scope.addUser = function() {
    $scope.users.push({
      id: $scope.users.length+1,
      name: '',
      status: null,
      group: null,
      isNew: true
    });
  };

这是 fiddle 我想出的解决问题的方法。

我在 addUser 方法中添加了一个 setFocus 函数调用

    $timeout( function() { 
        $scope.setFocus('name', $scope.users.length - 1); 
    }, 50);

    $scope.setFocus = function (id, index) {
        angular.element( document.querySelectorAll("#" + id))[index].focus(); 
    };