Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. import { Component } from 'angular2/core';
  2. import { NgIf } from 'angular2/common';
  3. import { RouteConfig, ROUTER_DIRECTIVES, AsyncRoute } from 'angular2/router';
  4.  
  5. import { CrisisCenterComponent} from './crisis-center/crisis-center.component';
  6. import { IdentityServerAuth } from './auth.component'
  7.  
  8. declare var System: any;
  9.  
  10. @Component({
  11. selector: 'app',
  12. template: `
  13. <a href="javascript:void(0)" (click)="auth.login()" *ngIf="auth.isLoggedIn === false">Login</a>
  14. <a href="javascript:void(0)" (click)="auth.logout()" *ngIf="auth.isLoggedIn">Logout</a>
  15. <router-outlet></router-outlet>
  16. `,
  17. directives: [ROUTER_DIRECTIVES]
  18. })
  19. @RouteConfig([
  20. {
  21. path: '/crisis-center/...',
  22. name: 'CrisisCenter',
  23. component: CrisisCenterComponent,
  24. useAsDefault: true
  25. },
  26. new AsyncRoute({
  27. path: '/private',
  28. name: "PrivateRoute",
  29. loader: () => ComponentHelper.LoadComponentAsync('PrivateRoute', '../app/private/private-route.component')
  30. }),
  31. ])
  32. export class AppComponent
  33. {
  34. constructor(public auth: IdentityServerAuth)
  35. {
  36. }
  37. }
  38.  
  39. class ComponentHelper
  40. {
  41. static LoadComponentAsync(name, path)
  42. {
  43. return System.import(path).then(c => c[name]);
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement