title: Conditional Based Auth Guard in angular routing. (Route Protection not just navigation only)
body: <p>I am creating one angular2 app.</p>
  <pre><code>export const routes: Route[] = [
  {path: '',redirectTo: &quot;login&quot;,pathMatch: &quot;full&quot; }, 
  {path: 'login', component: LoginComponent }, 
  {path: 'dashboard', component: DashboardComponent,canActivate:[AuthGuard], children:
      [
          { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
          { path: 'A', component: AComponent },
          { path: 'B', component: BComponent },
  
          { path: 'C', component: CComponent },
          { path: 'D', component: DComponent },
      ]
  }];
  </code></pre>
  <p>When i login to my app using LoginComponent it will go to DashboardComponent which have four child components</p>
  <ol>
  <li>-A</li>
  <li>-B</li>
  <li>-C</li>
  <li>-D</li>
  </ol>
  <p>Now i have by default set redirectTo to my dashboard component. but in place of this redirect i want to redirect to route A,B,C,D on the basis of type of login like wherether he is admin, superadmin, student or teacher.</p>
  <p>Suppose</p>
  <p><strong>If Login User is &quot;Admin&quot; he should be redirectTo - &gt; dashboard/A</strong></p>
  <p><strong>If Login User is &quot;Teacher&quot; then he should be redirectTo - &gt;dashboard/B</strong></p>
  <p>i have create authGuard like this</p>
  <pre><code>@Injectable()
  export class AuthGuard implements CanActivate {
  
      constructor(public router: Router){ }
  
      canActivate(){
          if(localStorage.getItem('userData')){
              return true;
          }
  
          // this.router.navigateByUrl('/');
          return false;
      }
  }
  
  export class activateEmployee implements CanActivate {
  
      constructor(){ }
  
      canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot){
          console.log(localStorage.getItem('userData'), &quot;employee&quot;);
          if(localStorage.getItem('userData') == 'superadmin'){
              return true;
          }
  
          // this.router.navigateByUrl('/');
          return false;
      }
  }
  
  export class activateSuperAdmin implements CanActivate {
  
      constructor(public router: Router){ }
  
      canActivate(){
          console.log(localStorage.getItem('userData'), &quot;Superadmin&quot;);
          if(localStorage.getItem('userData') == 'superadmin'){
              return true;
          }
  
          return false;
      }
  }
  
  export class activateAdmin implements CanActivate {
  
      constructor(public router: Router){ }
  
      canActivate(){
          console.log(localStorage.getItem('userData'),&quot;Admin&quot;);
          if(localStorage.getItem('userData') == 'admin'){
              return true;
          }
  
          return false;
      }
  }
  </code></pre>
  <blockquote>
  <p>PS: my main goal is to protect route that if someone knows the URL of protected route even than he is not able to go to there. or we can say i want something like multiple authGuard in a single service.</p>
  </blockquote>
  <h1>Update</h1>
  <p>Now i have created different classes for routing, but i am getting this error dont know why ?
  error is</p>
  <pre><code> Can't resolve all parameters for activateAdmin: (?).
  </code></pre>