Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. import { bind } from 'angular2/di';
  2. import { Component, View, bootstrap } from 'angular2/angular2';
  3. import { Route, Router, RouteConfig, RouteParams, LocationStrategy, HashLocationStrategy, routerInjectables, routerDirectives } from 'angular2/router';
  4.  
  5. @Component({
  6. selector: 'hello'
  7. })
  8. @View({
  9. template: `<p>Hello, {{ name }}!</p>`
  10. })
  11. class Hello {
  12. constructor() {
  13. this.name = 'Angular';
  14. }
  15. }
  16.  
  17. @Component({
  18. selector: 'ciao'
  19. })
  20. @View({
  21. template: `<p>Ciao, {{ name }}!</p>`
  22. })
  23. class Hello {
  24. constructor() {
  25. this.name = 'Angular';
  26. }
  27. }
  28.  
  29. @Component({
  30. selector: 'hello-app'
  31. })
  32. @View({
  33. directives: [Hello, routerDirectives],
  34. template: `
  35. <ul>
  36. <li><a [router-link]="['/hello']">Hello</a></li>
  37. <li><a [router-link]="['/ciao']">Ciao</a></li>
  38. </ul>
  39. <router-outlet></router-outlet>
  40. `
  41. })
  42. @RouteConfig([
  43. new Route({ path: '/', component: Hello, as: 'hello' }),
  44. new Route({ path: '/ciao', component: Ciao, as: 'ciao' })
  45. ])
  46. class HelloApp {
  47. constructor() {
  48. }
  49. }
  50.  
  51. bootstrap(HelloApp, [
  52. routerInjectables,
  53. bind(LocationStrategy).toClass(HashLocationStrategy)
  54. ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement