Skip to content

Commit 50070ba

Browse files
committed
(#6) Home Component
1 parent a1e4721 commit 50070ba

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

src/app/components/home/home.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/// <reference path="../../../typings/_custom.d.ts" />
2+
3+
/*
4+
* Angular 2
5+
* @Component: factory function
6+
* @View: factory function
7+
* @ViewEncapsulation: ENUM How the template and styles of a view should be encapsulated.
8+
*/
9+
import {Component, View, ViewEncapsulation} from 'angular2/angular2';
10+
11+
/*
12+
* Directives
13+
* @angularDirectives: Angular's core/form/router directives
14+
* @appDirectives: Our collection of directives from /directives
15+
*/
16+
import {appDirectives, angularDirectives} from 'app/directives/directives';
17+
18+
// Webpack's `require` to get files
19+
let styles = require('./styles/home.css');
20+
let template = require('./views/home.html');
21+
22+
// Simple external file component example
23+
@Component({
24+
selector: 'home'
25+
})
26+
@View({
27+
directives: [ angularDirectives, appDirectives ],
28+
encapsulation: ViewEncapsulation.EMULATED, // EMULATED: Emulate scoping of styles by preprocessing the style rules and adding additional attributes to elements.
29+
// include .html and .css file
30+
styles: [ styles ],
31+
template: template
32+
})
33+
export class Home {
34+
constructor() {
35+
36+
}
37+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.home {
2+
background-color: #F8F8F8;
3+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/// <reference path="../../../../typings/_custom.d.ts" />
2+
import {Component, View} from 'angular2/angular2';
3+
import {Home} from './home';
4+
5+
@Component({
6+
selector: 'test-cmp'
7+
})
8+
@View({
9+
directives: [ Home ]
10+
})
11+
class TestComponent {
12+
13+
}
14+
15+
describe('Home', () => {
16+
var home;
17+
18+
beforeEach(() => {
19+
home = new Home();
20+
});
21+
22+
it('should work', () => {
23+
expect(home).toBeDefined();
24+
});
25+
26+
});
27+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="home">
2+
<h2>Home</h2>
3+
</div>

0 commit comments

Comments
 (0)