Created
September 12, 2015 03:12
-
-
Save shuhei/96c68e5c3daed8cfcca5 to your computer and use it in GitHub Desktop.
Angular 2 alpha.36 with ES5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Hello = ng | |
.Component({ | |
selector: 'hello' | |
}) | |
.View({ | |
template: '<p>Hello, {{ name }}!</p>' | |
}) | |
.Class({ | |
constructor: function () { | |
this.name = 'angular'; | |
} | |
}); | |
var Ciao = ng | |
.Component({ | |
selector: 'ciao' | |
}) | |
.View({ | |
template: '<p>Ciao, {{ name }}!</p>' | |
}) | |
.Class({ | |
constructor: function () { | |
this.name = 'Angular'; | |
} | |
}); | |
var HelloApp = ng | |
.Component({ | |
selector: 'hello-app' | |
}) | |
.View({ | |
directives: [Hello, ngRouter.routerDirectives], | |
template: '\ | |
<ul>\ | |
<li><a [router-link]="[\'/hello\']">Hello</a></li>\ | |
<li><a [router-link]="[\'/ciao\']">Ciao</a></li>\ | |
</ul>\ | |
<router-outlet></router-outlet>\ | |
' | |
}) | |
.Class({ | |
constructor: function () { | |
} | |
}); | |
Reflect.getMetadata('annotations', HelloApp) | |
.push(new ngRouter.RouteConfig([ | |
{ path: '/', redirectTo: '/hello' }, | |
{ path: '/hello', component: Hello, as: 'hello' }, | |
{ path: '/ciao', component: Ciao, as: 'ciao' } | |
])); | |
document.addEventListener('DOMContentLoaded', function () { | |
ng.bootstrap(HelloApp, [ | |
ngRouter.routerInjectables, | |
ng.bind(ngRouter.LocationStrategy).toClass(ngRouter.HashLocationStrategy) | |
]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had to set RouteConfig as a metadata because it's not included in the chainable methods.