是否可以使用角度咏叹调进行咏叹调扩张?

时间:2016-01-05 10:49:40

标签: angularjs accessibility

我在互联网和Angular Aria文档上搜索过 - 它没有提到咏叹调扩展或咏叹调选择?

有没有办法实现这个?

<a href ng-aria={'expanded': selected} & ng-aria={'selected': selected}></a>

将会:

<a href aria-expanded="true" aria-selected="true"></a>

感谢。

2 个答案:

答案 0 :(得分:1)

不需要指令来设置aria扩展。只需使用表达式:

<a href="#" ng-init="selected=false" aria-expanded="{{selected}}" aria-selected="{{selected}}" ng-click="selected=!selected">link</a>

<p ng-show="selected">content<p>

答案 1 :(得分:1)

我用ng-bootstrap做到了。例如:

HTML

<p>
  <button type="button" class="btn btn-outline-primary" (click)="isCollapsed = !isCollapsed"
          [attr.aria-expanded]="!isCollapsed" aria-controls="collapseExample">
    Toggle
  </button>
</p>
<div id="collapseExample" [ngbCollapse]="isCollapsed">
  <div class="card">
    <div class="card-body">
      You can collapse this card by clicking Toggle
    </div>
  </div>
</div>

TYPESCRIPT

import { Component } from '@angular/core';

@Component({
  selector: 'ngbd-collapse-basic',
  templateUrl: './collapse-basic.html'
})
export class NgbdCollapseBasic {
  public isCollapsed = false;
}

来源:https://ng-bootstrap.github.io/#/components/collapse/examples