简体   繁体   English

如何使用 Tab 键在 Angular 的同一页面中的不同子组件之间导航?

[英]How is it possible to use the tab key to navigate between different child components in the same page with Angular?

For accessibility reasons, all components but be navigable with the tab key.出于可访问性的原因,所有组件都可以使用 tab 键导航。 I have two components on a login page but the tab won't take the focus from the component above to the one below.我在登录页面上有两个组件,但选项卡不会将焦点从上面的组件转移到下面的组件。

    <div class="content">
        <login-form
            [formBuilder]="fb"
            [submitting]="loginPageState.submitting"
        ></login-form>

        <div
            *ngIf="pageData.appSettings"
            class="login-page__link"
            [innerHtml]="pageData.appSettings.login_page_link | safe: 'html'"
        ></div>

        <login-identity
            (identity)="onIdentity($event)">
        </login-identity>
    </div>

Try to add tabindex attribute to your component: https://developer.mozilla.org/fr/docs/Web/HTML/Global_attributes/tabindex尝试将 tabindex 属性添加到您的组件: https://developer.mozilla.org/fr/docs/Web/HTML/Global_attributes/tabindex

For your component can use like this:对于您的组件,可以这样使用:

<login-identity
  tabindex=3
  (identity)="onIdentity($event)">
</login-identity>  

Or like: in your component ts file:或者像:在您的组件 ts 文件中:

@Component({
  selector: 'login-identity',
  ...
  host: {
    'tabindex': 3
  },
})
export class LoginIdentityComponent

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 角度6 - 是否可以在同一页面上使用两个角度元素组件? - Angular 6 - Is it possible to use two angular element components on the same page? 使用focus()函数导航到同一页面的“不同”选项卡中的元素 - Navigate to element in Different tab of same page using focus() function 如何在 Angular 的不同组件中使用注入服务的相同实例? - How to use same instance of an injected service across different components in Angular? 如何根据 React Native 中的条件在不同组件之间导航 - How to navigate between different components based on conditions in react native 如何从侧边栏链接导航到同一页面上的新 bootstap 4 选项卡? - How to navigate to a new bootstap 4 tab on the same page from a sidebar link? Angular:如何将 *ngFor 与父子组件一起使用 - Angular: How to use *ngFor with Parent Child components Angular 2在滚动的一组组件之间导航 - Angular 2 navigate between a set of components on scroll 在不同组件之间导航 React Native - Navigate between different components React Native 是否可以在不同的模块组件之间以角度共享数据 - Is is possible to share data between different Modules components in angular 是否可以在同一页面上组合使用不同版本的模板构建的 Web 组件? - Is it possible to combine web components built with different versions of stencil on the same page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM