Skip to content

Instantly share code, notes, and snippets.

@sandeepthukral
Created January 25, 2022 09:11
Show Gist options
  • Save sandeepthukral/d5723f39405444eddd28c16b6e1eb217 to your computer and use it in GitHub Desktop.
Save sandeepthukral/d5723f39405444eddd28c16b6e1eb217 to your computer and use it in GitHub Desktop.
Adding test attributes to angular HTML code

For adding data-test atributes to regular HTML tags

If the data is hard coded <th data-test="foo">

If the value has code <th [attr.data-test]="'foo-' + data.bar" Here data is an object available to the code (as props) from which you extract the value of the key bar and add it to the static text foo-

For adding data-test attributes to angular components

you will need for the componnet to support this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment