我正在尝试将焦点返回到使用<button>
调用自定义提醒的ViewChid
。
在我的组件中,我有:
@ViewChild('refocus') reFocus: any;
removeCancel() {
this.reFocus.nativeElement.focus();
}
在我的模板中,我将#refocus
添加到:
<button #refocus class="fbtn2" href="javascript:void(0)" (click)="removeDriver(index)">REMOVE</button>
<cp-confirmAlert (confirmCancel)="removeCancel()" (confirmAction)="removeConfirm()"></cp-confirmAlert>
我的问题是,页面上可以有多个REMOVE按钮。点击时我有index
但是没有我尝试的东西,焦点设置为第一个而不是索引#2 ..任何人都知道我缺少什么?