all files / src/app/utils/ external-link.directive.js

100% Statements 5/5
100% Branches 0/0
100% Functions 2/2
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24                                     
export default function () {
  function link(scope, el, attrs) {
    const url = attrs.externalLink;
    const tmpl = `
      <a href="${url}"
        target="_blank"
        title="View page on GitHub"
        class="text-decoration-none absolute right-0 top-0">
        <i
          class="material-icons absolute top-0"
          style="font-size: 18px; right: -1.5rem;">
          open_in_new
        </i>
      </a>`;
    el.addClass('relative');
    el.append(tmpl);
  }
 
  return {
    restrict: 'A',
    link
  };
}