Reputation: 5238
I have the following compontent
<mat-form-field>
<mat-placeholder i18n="@@Title4Version">Title for version</mat-placeholder>
<input matInput [(ngModel)]="workflowInfo.title" readonly [readOnly]="lockTitle">
<button mat-button matSuffix mat-stroked-button aria-label="Unlock" (click)="lockTitle=!lockTitle">
<ng-container *ngIf="lockTitle; else unlocked">
<mat-icon>lock_open</mat-icon>
</ng-container>
<ng-template #unlocked>
<mat-icon>lock</mat-icon>
</ng-template>
</button>
</mat-form-field>
Which looks like the following screen shot:
My question: Is it possible to
aria-label
accordingly set (i.e. either 'Unlock' or 'Lock') ANDI have an idea how to accomplish question 1 but how to have the other 2 options as well? Is it possible to have them all in one template? If not how to split them up properly
(without code duplication)?
Upvotes: 1
Views: 4807
Reputation: 17918
You already have most of the code in place - just bind the aria-label attribute to an expression:
[attr.aria-label]="lockTitle ? 'Unlock' : 'Lock'"
And you appear to already be using template translations so you can probably use the translate attributes feature: https://angular.io/guide/i18n#translate-attributes.
i18n-aria-label
Upvotes: 3