Skip to content

Instantly share code, notes, and snippets.

@shuhei
Created September 12, 2015 03:12
Show Gist options
  • Save shuhei/96c68e5c3daed8cfcca5 to your computer and use it in GitHub Desktop.
Save shuhei/96c68e5c3daed8cfcca5 to your computer and use it in GitHub Desktop.
Angular 2 alpha.36 with ES5
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)
]);
});
@shuhei
Copy link
Author

shuhei commented Sep 12, 2015

I had to set RouteConfig as a metadata because it's not included in the chainable methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment