Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template-accessibility-label-for: not recognizing id/for attributes with interpolated values #808

Closed
ChrisMBarr opened this issue Apr 8, 2019 · 0 comments · Fixed by #812
Assignees
Labels

Comments

@ChrisMBarr
Copy link

Describe the bug

The new template-accessibility-label-for rule seems to not recognize associated id/for attributes that contain interpolated values such as item-{{index}} that would typically be used when a component generates input controls inside of an ngFor loop.

Context and configuration

"template-accessibility-label-for": true,

Code & Expected behavior

<ng-container *ngFor="let item of itemList; let i = index">
    <label for="item-{{i}}">My label #{{i}</label>
    <input type="text" id="item-{{i}}" [(ngModel)]="item.name"/>
</ng-container>

The above code will generate unique ID's that associate the control with the label within a loop, yet it produces the error

ERROR: 19:12  template-accessibility-label-for       A form label must be associated with a control

Environment

  • Version 5.0.0
  • OS: Windows 10
  • Node.js version 11.4.0
  • Package manager (yarn/npm) version NPM 6.9.0
  • Angular version 7.2.12
  • tslint version 5.15.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants