如何解决将焦点元素设置为<i class>而不是按钮
如何将焦点设置为图标类而不是按钮或输入字段。
如果我尝试着重于Button或Input元素,它将起作用,但不适用于图标类或任何其他div类。
我有一个“关闭”按钮,如果服务呼叫失败,则屏幕应一直向上直到显示的图标错误。
**Html**
<!-- Works with this -->
<button #onChange>Mustrame</button>
<!-- But not with this no matter where I locate the id -->
<div class="row">
<div class="col-2">
<i class="some-icon" #onChange></i>
</div>
</div>
**Component**
import {Component,Inject,PLATFORM_ID,ViewChild,AfterViewInit} from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
....
export class errorClass implements AfterViewInit{
@ViewChild('focusID',{static: false}) changeFocus: any;
constructor( @Inject(PLATFORM_ID) private platformId: Object) {}
ngAfterViewInit() {
this.changeFocus.nativeElement.focus();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。