forked from thelgevold/angular-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
39 lines (30 loc) · 1.07 KB
/
app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/// <reference path="typings/angular2/angular2.d.ts" />
import {HTTP_BINDINGS} from 'angular2/http';
import {Component, View, bootstrap, bind} from 'angular2/angular2';
import {DemoPage} from './demo-page';
import {About} from './components/about/about';
import {ROUTER_BINDINGS, LocationStrategy, HashLocationStrategy} from 'angular2/router';
import {RouterLink, RouteConfig, Router, RouterOutlet, Location, RouteParams} from 'angular2/router';
@Component({
selector: 'demo-app'
})
@View({
templateUrl: './demo-app.html',
directives:[DemoPage, RouterLink, RouterOutlet, About]
})
@RouteConfig([
{path: '/', component: DemoPage, as: 'home'},
{path: '/about/:id', component: About, as: 'about'}
])
class MyDemoApp {
router: Router;
location: Location;
constructor(router: Router, location: Location) {
this.router = router;
this.location = location;
}
getLinkStyle(path) {
return this.location.path() === path;
}
}
bootstrap(MyDemoApp,[HTTP_BINDINGS,ROUTER_BINDINGS, bind(LocationStrategy).toClass(HashLocationStrategy)]);