|
1 | | -/// <reference path="../../../typings/_custom.d.ts" /> |
2 | | - |
3 | | -/* |
4 | | - * Angular 2 |
5 | | - */ |
6 | | -import {Component, View, Directive, ElementRef} from 'angular2/angular2'; |
7 | | - |
8 | | -let view = require('./views/dashboard.html'); |
9 | | - |
10 | | -/* |
11 | | - * TODO: refactor |
12 | | - * simple example directive that should be in `/directives` folder |
13 | | - */ |
14 | | -@Directive({ |
15 | | - selector: '[x-large]' // using [ ] means selecting attributes |
16 | | -}) |
17 | | -class XLarge { |
18 | | - constructor(public el: ElementRef) { |
19 | | - // simple dom manipulation to set font size to x-large |
20 | | - if (this.el.nativeElement.style) { |
21 | | - this.el.nativeElement.style.fontSize = 'x-large'; |
22 | | - } |
23 | | - } |
24 | | -} |
25 | | - |
26 | | -// Simple component with custom directive example |
27 | | -@Component({ |
28 | | - selector: 'dashboard' |
29 | | -}) |
30 | | -@View({ |
31 | | - directives: [ XLarge ], |
32 | | - template: view |
33 | | -}) |
34 | | -export class Dashboard { |
35 | | - constructor() { |
36 | | - |
37 | | - } |
38 | | -} |
| 1 | +/// <reference path="../../../typings/_custom.d.ts" /> |
| 2 | + |
| 3 | +/* |
| 4 | + * Angular 2 |
| 5 | + */ |
| 6 | +import {Component, View, Directive, coreDirectives, ElementRef} from 'angular2/angular2'; |
| 7 | + |
| 8 | +// Directives |
| 9 | +import {Structure} from './directives/structure'; |
| 10 | + |
| 11 | +// View |
| 12 | +let view = require('./views/dashboard.html'); |
| 13 | + |
| 14 | +// Styles |
| 15 | +let styles = require('./styles/dashboard.css'); |
| 16 | + |
| 17 | + |
| 18 | +@Directive({ |
| 19 | + selector: '[x-large]' // using [ ] means selecting attributes |
| 20 | +}) |
| 21 | +class XLarge { |
| 22 | + constructor(public el: ElementRef) { |
| 23 | + // simple dom manipulation to set font size to x-large |
| 24 | + if (this.el.nativeElement.style) { |
| 25 | + this.el.nativeElement.style.fontSize = 'x-large'; |
| 26 | + } |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +// Simple component with custom directive example |
| 31 | +@Component({ |
| 32 | + selector: 'dashboard' |
| 33 | +}) |
| 34 | +@View({ |
| 35 | + directives: [ coreDirectives, XLarge, Structure ], |
| 36 | + template: view, |
| 37 | + styles: [styles] |
| 38 | +}) |
| 39 | +export class Dashboard { |
| 40 | + constructor() { |
| 41 | + |
| 42 | + } |
| 43 | +} |
0 commit comments