SHARE
TWEET

Untitled

a guest Aug 18th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Directive, ElementRef, HostListener } from '@angular/core';
  2. import { Router } from '@angular/router';
  3.  
  4. @Directive({
  5.   selector: '[upRouteTransformer]'
  6. })
  7. export class RouteTransformerDirective {
  8.  
  9.   constructor(private el: ElementRef, private router: Router) { }
  10.  
  11.   @HostListener('click', ['$event'])
  12.   public onClick(event) {
  13.     if (event.target.tagName === 'A') {
  14.       this.router.navigate([event.target.getAttribute('href')]);
  15.       event.preventDefault();
  16.     } else {
  17.       return;
  18.     }
  19.   }
  20.  
  21. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top