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

Commit 0f732c3

Browse files
committed
fixed a few code samples
1 parent 0c99a67 commit 0f732c3

File tree

3 files changed

+54
-33
lines changed

3 files changed

+54
-33
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// #docregion
2+
import { Directive, HostBinding, HostListener } from 'angular2/core';
3+
4+
// #docregion example
5+
@Directive({
6+
selector: '[tohValidator]'
7+
})
8+
export class ValidatorDirective {
9+
@HostBinding('attr.role') role = 'button';
10+
@HostListener('mouseenter') onMouseEnter() {
11+
// do work
12+
}
13+
}
14+
export class ValidateDirective { }
15+
// #enddocregion example
16+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// #docregion
2+
import { Directive, HostBinding, HostListener } from 'angular2/core';
3+
4+
// #docregion example
5+
/* avoid */
6+
7+
@Directive({
8+
selector: '[tohValidator]',
9+
host: {
10+
'(mouseenter)': 'onMouseEnter()',
11+
'attr.role': 'button'
12+
}
13+
})
14+
export class ValidatorDirective {
15+
role = 'button';
16+
onMouseEnter() {
17+
// do work
18+
}
19+
}
20+
export class ValidateDirective { }
21+
// #enddocregion example

public/docs/ts/latest/guide/style-guide.jade

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,17 @@ a(href="#toc") Back to top
243243
:marked
244244
**Why?** The `Component` suffix is more commonly used and is more explicitly descriptive.
245245

246-
```
247-
/* recommended */
248-
AppComponent // app.component.ts
249-
HeroesComponent // heroes.component.ts
250-
HeroListComponent // hero-list.component.ts
251-
HeroDetailComponent // hero-detail.component.ts
246+
:marked
247+
```
248+
/* recommended */
249+
AppComponent // app.component.ts
250+
HeroesComponent // heroes.component.ts
251+
HeroListComponent // hero-list.component.ts
252+
HeroDetailComponent // hero-detail.component.ts
252253

253-
/* recommended */
254-
ValidationDirective // validation.directive.ts
255-
```
254+
/* recommended */
255+
ValidationDirective // validation.directive.ts
256+
```
256257

257258
a(href="#toc") Back to top
258259

@@ -286,6 +287,7 @@ a(href="#toc") Back to top
286287
:marked
287288
**Why?** Service names such as `Credit` are nouns and require a suffix and should be named with a suffix when it is not obvious if it is a service or something else.
288289

290+
:marked
289291
```
290292
HeroDataService // hero-data.service.ts
291293
CreditService // credit.service.ts
@@ -415,6 +417,7 @@ a(href="#toc") Back to top
415417
:marked
416418
**Why?** Provides a consistent way to quickly identify and reference pipes.
417419

420+
:marked
418421
```
419422
EllipsisPipe // ellipsis.pipe.ts
420423
InitCapsPipe // init-caps.pipe.ts
@@ -444,6 +447,7 @@ a(href="#toc") Back to top
444447
:marked
445448
**Why?** Provides pattern matching for [karma](http://karma-runner.github.io/) or other test runners.
446449

450+
:marked
447451
```
448452
// recommended
449453

@@ -483,6 +487,7 @@ a(href="#toc") Back to top
483487
:marked
484488
**Why?** Provides pattern matching for test runners and build automation.
485489

490+
:marked
486491
```
487492
// recommended
488493
app.e2e-spec.ts
@@ -1547,32 +1552,11 @@ a(href="#toc") Back to top
15471552
:marked
15481553
**Why?** The metadata declaration attached to the directive is shorter and thus more readable.
15491554

1555+
+makeExample('style-guide/ts/06-03/app/shared/validate.directive.ts', 'example', 'app/shared/validate.directive.ts')(avoid=1)
15501556
:marked
1551-
```
1552-
/* avoid */
1553-
@Directive({
1554-
selector: '[tohValidator]',
1555-
host: {
1556-
'(mouseenter)': 'onMouseEnter()',
1557-
'attr.role': 'button'
1558-
}
1559-
})
1560-
export class ValidatorDirective {
1561-
role = 'button';
1562-
onMouseEnter() {...}
1563-
}
1564-
```
15651557

1566-
```
1567-
/* recommended */
1568-
@Directive({
1569-
selector: '[tohValidator]'
1570-
})
1571-
export class ValidatorDirective {
1572-
@HostBinding('attr.role') role = 'button';
1573-
@HostListener('mouseenter') onMouseEnter() {...}
1574-
}
1575-
```
1558+
+makeExample('style-guide/ts/06-03/app/shared/validate.directive.ts', 'example', 'app/shared/validate.directive.ts')
1559+
:marked
15761560

15771561
a(href="#toc") Back to top
15781562

0 commit comments

Comments
 (0)