Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 43875ac

Browse files
committed
docs(cb-di): more Ward tweaks
1 parent 16d2e8c commit 43875ac

File tree

9 files changed

+242
-40
lines changed

9 files changed

+242
-40
lines changed

gulpfile.js

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ var _exampleBoilerplateFiles = [
7474
'package.json',
7575
'styles.css',
7676
'tsconfig.json',
77+
'tslint.json',
7778
'typings.json'
7879
];
7980

public/docs/_examples/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ package.json
66
karma.conf.js
77
karma-test-shim.js
88
tsconfig.json
9+
tslint.json
910
npm-debug*.
1011
**/protractor.config.js

public/docs/_examples/cb-dependency-injection/ts/app/app.component.html

+2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ <h3>Hero Bios</h3>
1010
<hero-bios></hero-bios>
1111
</div>
1212

13+
<!-- #docregion highlight -->
1314
<div id="highlight" class="di-component" myHighlight>
1415
<h3>Hero Bios and Contacts</h3>
1516
<div myHighlight="yellow">
1617
<hero-bios-and-contacts></hero-bios-and-contacts>
1718
</div>
1819
</div>
20+
<!-- #enddocregion highlight -->
1921

2022
<div class="di-component">
2123
<hero-of-the-month></hero-of-the-month>

public/docs/_examples/cb-dependency-injection/ts/app/app.component.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,29 @@ import { HeroesBaseComponent,
99
import { HighlightDirective } from './highlight.directive';
1010
import { ParentPasserComponent } from './parent-passer.component';
1111

12+
const DIRECTIVES = [
13+
HeroBiosComponent, HeroBiosAndContactsComponent,
14+
HeroesBaseComponent, SortedHeroesComponent,
15+
HeroOfTheMonthComponent,
16+
HighlightDirective,
17+
ParentPasserComponent
18+
];
19+
1220
// #docregion import-services
1321
import { LoggerService } from './logger.service';
1422
import { UserContextService } from './user-context.service';
1523
import { UserService } from './user.service';
16-
// #enddocregion import-services
1724

1825
@Component({
1926
selector: 'my-app',
2027
templateUrl:'app/app.component.html',
21-
directives: [
22-
HeroBiosComponent, HeroBiosAndContactsComponent,
23-
HeroesBaseComponent, SortedHeroesComponent,
24-
HeroOfTheMonthComponent,
25-
HighlightDirective,
26-
ParentPasserComponent
27-
],
28+
directives: DIRECTIVES,
2829
// #docregion providers
2930
providers: [LoggerService, UserContextService, UserService]
3031
// #enddocregion providers
3132
})
32-
3333
export class AppComponent {
34+
// #enddocregion import-services
3435

3536
private userId:number = 1;
3637

@@ -40,4 +41,6 @@ export class AppComponent {
4041
logger.logInfo('AppComponent initialized');
4142
}
4243
// #enddocregion ctor
44+
// #docregion import-services
4345
}
46+
// #enddocregion import-services

public/docs/_examples/cb-dependency-injection/ts/app/hero-bios.component.ts

+2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ export class HeroBiosComponent{
4040
<hero-bio [heroId]="3"> <hero-contact></hero-contact> </hero-bio>`,
4141
// #enddocregion template
4242
directives:[HeroBioComponent, HeroContactComponent],
43+
// #docregion class-provider
4344
providers: [HeroService]
45+
// #enddocregion class-provider
4446
})
4547
export class HeroBiosAndContactsComponent{
4648
constructor(logger: LoggerService) {

public/docs/_examples/cb-dependency-injection/ts/app/hero-of-the-month.component.ts

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
// #docplaster
12
// #docregion opaque-token
23
import {OpaqueToken} from 'angular2/core';
34

45
export const TITLE = new OpaqueToken('title');
56
// #enddocregion opaque-token
67

7-
// #docregion
8+
// #docregion hero-of-the-month
89
import { Component, Inject, provide } from 'angular2/core';
910

1011
import { DateLoggerService,
@@ -15,9 +16,12 @@ import { LoggerService } from './logger.service';
1516
import { RunnersUp } from './runners-up';
1617
import { runnersUpFactory } from './runners-up-provider.service';
1718

18-
@Component({
19-
selector:'hero-of-the-month',
20-
template:`
19+
// #enddocregion hero-of-the-month
20+
// #docregion some-hero
21+
const someHero = new Hero(42, 'Magma','Had a great month!','555-555-5555');
22+
// #enddocregion some-hero
23+
24+
const template = `
2125
<h3>{{title}}</h3>
2226
<div>Winner: <strong>{{_heroOfTheMonth.name}}</strong></div>
2327
<div>Reason for award: <strong>{{_heroOfTheMonth.description}}</strong></div>
@@ -27,13 +31,19 @@ import { runnersUpFactory } from './runners-up-provider.service';
2731
<div id="logs">
2832
<div *ngFor="#log of logs">{{log}}</div>
2933
</div>
30-
`,
34+
`;
3135

36+
// #docregion hero-of-the-month
37+
@Component({
38+
selector:'hero-of-the-month',
39+
template: template,
3240
// #docregion providers
3341
providers:[
34-
HeroService,
35-
provide(Hero, {useValue: new Hero(42, 'Magma','Had a great month!','555-555-5555')}),
42+
provide(Hero, {useValue: someHero}),
43+
// #docregion use-class
44+
provide(HeroService, {useClass: HeroService}),
3645
provide(LoggerService, {useClass: DateLoggerService}),
46+
// #enddocregion use-class
3747
provide(MinimalLogger, {useExisting: LoggerService}),
3848
provide(RunnersUp, {useFactory: runnersUpFactory, deps:[Hero, HeroService]}),
3949
provide(TITLE, {useValue: 'Hero of the Month'})
@@ -55,4 +65,4 @@ export class HeroOfTheMonthComponent {
5565
}
5666
}
5767
// #enddocregion class
58-
// #enddocregion
68+
// #enddocregion hero-of-the-month

public/docs/_examples/cb-dependency-injection/ts/app/highlight.directive.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// #docplaster
22
// #docregion
3-
import {Directive, ElementRef, Input, Renderer} from 'angular2/core';
3+
import {Directive, ElementRef, Input} from 'angular2/core';
44

55
@Directive({
66
selector: '[myHighlight]',
@@ -13,7 +13,7 @@ export class HighlightDirective {
1313

1414
@Input('myHighlight') highlightColor: string;
1515

16-
private _el:HTMLElement;
16+
private _el: HTMLElement;
1717

1818
constructor(el: ElementRef) {
1919
this._el = el.nativeElement;

public/docs/_examples/tslint.json

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"rules": {
3+
"class-name": true,
4+
"comment-format": [
5+
true,
6+
"check-space"
7+
],
8+
"curly": true,
9+
"eofline": true,
10+
"forin": true,
11+
"indent": [
12+
true,
13+
"spaces"
14+
],
15+
"label-position": true,
16+
"label-undefined": true,
17+
"max-line-length": [
18+
true,
19+
140
20+
],
21+
"member-access": false,
22+
"member-ordering": [
23+
true,
24+
"static-before-instance",
25+
"variables-before-functions"
26+
],
27+
"no-arg": true,
28+
"no-bitwise": true,
29+
"no-console": [
30+
true,
31+
"debug",
32+
"info",
33+
"time",
34+
"timeEnd",
35+
"trace"
36+
],
37+
"no-construct": true,
38+
"no-debugger": true,
39+
"no-duplicate-key": true,
40+
"no-duplicate-variable": true,
41+
"no-empty": false,
42+
"no-eval": true,
43+
"no-inferrable-types": true,
44+
"no-shadowed-variable": true,
45+
"no-string-literal": false,
46+
"no-switch-case-fall-through": true,
47+
"no-trailing-whitespace": true,
48+
"no-unused-expression": true,
49+
"no-unused-variable": true,
50+
"no-unreachable": true,
51+
"no-use-before-declare": true,
52+
"no-var-keyword": true,
53+
"object-literal-sort-keys": false,
54+
"one-line": [
55+
true,
56+
"check-open-brace",
57+
"check-catch",
58+
"check-else",
59+
"check-whitespace"
60+
],
61+
"quotemark": [
62+
true,
63+
"single"
64+
],
65+
"radix": true,
66+
"semicolon": [
67+
"always"
68+
],
69+
"triple-equals": [
70+
true,
71+
"allow-null-check"
72+
],
73+
"typedef-whitespace": [
74+
true,
75+
{
76+
"call-signature": "nospace",
77+
"index-signature": "nospace",
78+
"parameter": "nospace",
79+
"property-declaration": "nospace",
80+
"variable-declaration": "nospace"
81+
}
82+
],
83+
"variable-name": false,
84+
"whitespace": [
85+
true,
86+
"check-branch",
87+
"check-decl",
88+
"check-operator",
89+
"check-separator",
90+
"check-type"
91+
]
92+
}
93+
}

0 commit comments

Comments
 (0)