Skip to content

Instantly share code, notes, and snippets.

@andlewis
Created May 29, 2019 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andlewis/7192b1d37024cf812417807b261dcf97 to your computer and use it in GitHub Desktop.
Save andlewis/7192b1d37024cf812417807b261dcf97 to your computer and use it in GitHub Desktop.
Angular - add a ping attribute to every a tag on the page
ngAfterViewChecked() {
let count = 0;
Array.from(document.getElementsByTagName('a')).filter((x: any) => !x.ping).forEach((x: any) => { x.ping = this.metricsUrl; count++ });
if (count > 0) {
console.log(`ngAfterViewChecked. ${count} linked updated`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment