Skip to content

Commit 1975a2c

Browse files
committed
(#3) entry file for components
1 parent 2a544e0 commit 1975a2c

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

src/app/components/app.ts

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/// <reference path="../../typings/_custom.d.ts" />
2+
3+
/*
4+
* Angular 2
5+
*/
6+
import {Component, View} from 'angular2/angular2';
7+
import {RouteConfig} from 'angular2/router';
8+
9+
/*
10+
* Directives
11+
*/
12+
import {coreDirectives, formDirectives} from 'angular2/angular2';
13+
import {routerDirectives} from 'angular2/router';
14+
// Import all of our custom app directives
15+
import {appDirectives} from '../directives/directives';
16+
17+
/*
18+
* App Pipes
19+
* our collection of pipes registry
20+
*/
21+
import {appPipes} from '../pipes/pipes';
22+
23+
/*
24+
* Components
25+
*/
26+
/* TODO: Create these Components
27+
// We use a folder if we want separate files
28+
import {Home} from './home/home';
29+
// Otherwise we only use one file for a component
30+
import {Dashboard} from './dashboard';
31+
// A simple example of a Component using a Service
32+
import {Todo} from './todo';
33+
34+
// RxJs examples
35+
import {RxJsExamples} from './rxjs-examples/rxjs-examples';
36+
*/
37+
// Use webpack's `require` to get files as a raw string using raw-loader
38+
let styles = require('./app.css');
39+
40+
/*
41+
* App Component
42+
* Top Level Component
43+
* Simple router component example
44+
*/
45+
@Component({
46+
selector: 'app', // without [ ] means we are selecting the tag directly
47+
viewBindings: [ appPipes ]
48+
})
49+
@View({
50+
// needed in order to tell Angular's compiler what's in the template
51+
directives: [
52+
// Angular's core directives
53+
coreDirectives,
54+
55+
// Angular's form directives
56+
formDirectives,
57+
58+
// Angular's router
59+
routerDirectives,
60+
61+
// Our collection of directives from /directives
62+
appDirectives
63+
],
64+
// include our .css file
65+
styles: [ styles ],
66+
template: `
67+
<header>
68+
<div layout="row" class="top-nav ac-default-theme">
69+
<img src="angular-shield.png" alt="Angular2" height="54" width="54">
70+
<span class="logo">{{ name | capitalize }} + Webpack</span>
71+
<ul>
72+
<li class="l-left">
73+
<a [router-link]=" ['/home'] "class="top-nav-button ac-default-theme">Home</a>
74+
</li>
75+
<li class="l-left">
76+
<a [router-link]=" ['/dashboard'] "class="top-nav-button ac-default-theme">Dashboard</a>
77+
</li>
78+
<li class="l-left">
79+
<a [router-link]=" ['/todo'] "class="top-nav-button ac-default-theme">Todo</a>
80+
</li>
81+
<li class="l-left">
82+
<a [router-link]=" ['/rxjs-examples', 'search'] "class="top-nav-button ac-default-theme">RxJs Examples</a>
83+
</li>
84+
</ul>
85+
</div>
86+
</header>
87+
88+
<main>
89+
<router-outlet></router-outlet>
90+
</main>
91+
92+
<footer>
93+
WebPack Angular 2 Starter by <a href="https://twitter.com/AngularClass">@AngularClass</a>
94+
</footer>
95+
`
96+
})
97+
@RouteConfig([
98+
/* TODO: create these components
99+
{ path: '/', as: 'home', component: Home },
100+
{ path: '/dashboard', as: 'dashboard', component: Dashboard },
101+
{ path: '/todo', as: 'todo', component: Todo },
102+
{ path: '/rxjs-examples/...', as: 'rxjs-examples', component: RxJsExamples }
103+
*/
104+
])
105+
export class App {
106+
name: string;
107+
constructor() {
108+
this.name = 'angular';
109+
}
110+
}

0 commit comments

Comments
 (0)