title: Protecting views, authentication or canActivate for Angular 2 with ui-router
body: <p>I thought I could try using <code>ui-router</code> with Angular 2.</p>
  
  <p>Currently, I already have some default <code>angular2-router</code> configuration, which mostly comes down to something like:</p>
  
  <pre><code>export const homeRoute: Route = {
    path: '',
    component: HomeComponent,
    canActivate: [AuthGuard]
  };
  </code></pre>
  
  <p><code>ui-router</code> docs shows a similar example, <a href="https://ui-router.github.io/docs/latest/modules/ng2.html" rel="nofollow noreferrer">docs</a>:</p>
  
  <pre><code>export let state1: Ng2StateDeclaration = {
    name: 'state1',
    component: State1Component,
    url: '/one'
  }
  </code></pre>
  
  <p>Which would do just fine, but for one missing key: <code>canActivate</code>.</p>
  
  <p>In Angular 1 I have used a great lib: <a href="https://github.com/Narzerus/angular-permission" rel="nofollow noreferrer">angular-permission</a> but it is not available for Angular 2.</p>
  
  <p>I do not need fancy permissions at the moment, a simple true/false authentication would do, however, I simply do not know how to protected my routes.</p>
  
  <p>I have tried searching but the topic is so fresh, there are no examples available. </p>
  
  <p>Thanks for all the ideas.</p>