title: Angular 2 get current route in guard
body: <p>I have an AccessGuard class in my project which its work is to determine if user can access to the route or not. I used the <code>router.url</code> to get the current route but the url returns the route before navigation to the new route like I'm in the users route and I click on the candidates route so the url returns users instead of candidates which I want that to validate access to the route
  this is my route file:</p>
  
  <pre><code>const routes:Routes = [
  {
      path:'',
      component:PanelComponent,
      canActivate:[AuthGuard,AccessGuard],
      canActivateChild:[AuthGuard,AccessGuard],
      children:[
          {
              path:'dashboard',
              component:DashboardComponent
          },
          {
              path:'users',
              component:UsersComponent
          },
          {
              path:'users/:id',
              component:ShowUserComponent
          },
          {
              path:'candidates',
              component:CandidatesComponent
          },
          {
              path:'permissions',
              component:PermissionsComponent
          },
          {
              path:'holidays',
              component:HolidaysComponent
          },
          {
              path:'candidate/:id',
              component:CandidateComponent
          },
          {
              path:'salary/create',
              component:InsertSalaryComponent
          },
          {
              path:'document/create',
              component:InsertDocumentComponent
          },
          {
              path:'leave/create',
              component:InsertLeaveComponent
          }
      ]
  }
  
  ];
  </code></pre>
  
  <p>and this is my access guard:</p>
  
  <pre><code>permissions;
  currentRoute;
  constructor(private authService:AuthService,private router:Router){
      this.permissions = this.authService.getPermissions();
  }
  
  canActivate(){
      return this.checkHavePermission();
  }
  
  canActivateChild(){
      console.log(this.router.url);
      return this.checkHavePermission();
  }
  
  private checkHavePermission(){
      switch (this.router.url) {
          case "/panel/users":
              return this.getPermission('user.view');
          case '/panel/dashboard':
              return true;
          case '/panel/candidates':
              return this.getPermission('candidate.view');
          default:
              return true;
      }
  }
  
  
  getPermission(perm){
      for(var i=0;i&lt;this.permissions.length;i++){
          if(this.permissions[i].name == perm ){
              return true;
          }
      }
      return false;
  }
  </code></pre>