forked from PatrickJS/angular-webpack-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
64 lines (55 loc) · 1.93 KB
/
Copy pathapp.ts
File metadata and controls
64 lines (55 loc) · 1.93 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/// <reference path="../../../typings/tsd.d.ts" />
/// <reference path="../../custom_typings/ng2.d.ts" />
// Angular 2
import {Component, View, coreDirectives} from 'angular2/angular2';
import {RouteConfig, RouterOutlet, RouterLink, Router} from 'angular2/router';
import {BrowserLocation} from 'angular2/src/router/browser_location';
// We use a folder if we want separate files
import {Home} from './home/home';
// Otherwise we only use one file for a component
import {Dashboard} from './dashboard';
// A simple example of a Component using a Service
import {Todo} from './todo';
// Import all of our custom app directives
import {appDirectives} from '../directives/directives';
// App: Top Level Component
@Component({
selector: 'app' // without [ ] means we are selecting the tag directly,
})
@View({
// needed in order to tell Angular's compiler what's in the template
directives: [ RouterOutlet, RouterLink, coreDirectives, appDirectives ],
template: `
<style>
.title { font-family: Arial, Helvetica, sans-serif; }
.nav { display: inline; list-style-type: none; padding: 0; background-color: #F8F8F8; }
.nav li { display: inline; }
main { padding: 0.5em; }
</style>
<h1 class="title">Hello {{ name }}</h1>
<ul class="nav">
<li><a router-link="home">Home</a></li>
|
<li><a router-link="dashboard">Dashboard</a></li>
|
<li><a router-link="todo">Todo</a></li>
</ul>
<main>
<router-outlet></router-outlet>
</main>
`
})
@RouteConfig([
{ path: '/', as: 'home', component: Home },
{ path: '/dashboard', as: 'dashboard', component: Dashboard },
{ path: '/todo', as: 'todo', component: Todo }
])
export class App {
name: string;
constructor(router: Router, browserLocation: BrowserLocation) {
this.name = 'Angular 2';
// we need to manually go to the correct uri until the router is fixed
let uri = browserLocation.path();
router.navigate(uri);
}
}