I searched on the Internet and the Angular Aria documentation - it didn't mention about aria-expanded or aria-selected?
Is there a way of implementing this?
<a href ng-aria={'expanded': selected} & ng-aria={'selected': selected}></a>
which will make:
<a href aria-expanded="true" aria-selected="true"></a>
Thanks.
I used ng-bootstrap to do it. For example:
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;
}
Source: https://ng-bootstrap.github.io/#/components/collapse/examples
No need for a directive to set aria-expanded. Just use an expression:
<a href="#" ng-init="selected=false" aria-expanded="{{selected}}" aria-selected="{{selected}}" ng-click="selected=!selected">link</a>
<p ng-show="selected">content<p>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With