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

Commit da08ad1

Browse files
committed
Ward's post-review updates
- Keep `my-` and `my` prefixes on selectors (for components and directives respectively). - Drop `my-` from file names. - Drop `My` as component class prefix.
1 parent a934ede commit da08ad1

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

public/docs/_examples/template-syntax/ts/app/app.component.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,10 @@ <h3>
305305

306306
<div>
307307
<!-- #docregion event-binding-3 -->
308-
<!-- `myClick` is an event on the custom `MyClickDirective` -->
309-
<!-- #docregion my-click -->
308+
<!-- `myClick` is an event on the custom `ClickDirective` -->
309+
<!-- #docregion myClick -->
310310
<div (myClick)="clickMessage=$event">click with myClick</div>
311-
<!-- #enddocregion my-click -->
311+
<!-- #enddocregion myClick -->
312312
<!-- #enddocregion event-binding-3 -->
313313
{{clickMessage}}
314314
</div>

public/docs/_examples/template-syntax/ts/app/app.module.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { FormsModule } from '@angular/forms';
44

55
import { AppComponent } from './app.component';
66
import { BigHeroDetailComponent, HeroDetailComponent } from './hero-detail.component';
7-
import { MyClickDirective, MyClickDirective2 } from './my-click.directive';
8-
import { MySizerComponent } from './my-sizer.component';
7+
import { ClickDirective, ClickDirective2 } from './click.directive';
8+
import { SizerComponent } from './sizer.component';
99

1010
@NgModule({
1111
imports: [
@@ -16,9 +16,9 @@ import { MySizerComponent } from './my-sizer.component';
1616
AppComponent,
1717
BigHeroDetailComponent,
1818
HeroDetailComponent,
19-
MyClickDirective,
20-
MyClickDirective2,
21-
MySizerComponent
19+
ClickDirective,
20+
ClickDirective2,
21+
SizerComponent
2222
],
2323
bootstrap: [ AppComponent ]
2424
})

public/docs/_examples/template-syntax/ts/app/my-click.directive.ts renamed to public/docs/_examples/template-syntax/ts/app/click.directive.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import { Directive, ElementRef, EventEmitter, Output } from '@angular/core';
44

55
@Directive({selector: '[myClick]'})
6-
export class MyClickDirective {
7-
// #docregion my-click-output-1
6+
export class ClickDirective {
7+
// #docregion output-myClick
88
@Output('myClick') clicks = new EventEmitter<string>(); // @Output(alias) propertyName = ...
9-
// #enddocregion my-click-output-1
9+
// #enddocregion output-myClick
1010

1111
toggle = false;
1212

@@ -19,15 +19,15 @@ export class MyClickDirective {
1919
}
2020
}
2121

22-
// #docregion my-click-output-2
22+
// #docregion output-myClick2
2323
@Directive({
24-
// #enddocregion my-click-output-2
24+
// #enddocregion output-myClick2
2525
selector: '[myClick2]',
26-
// #docregion my-click-output-2
26+
// #docregion output-myClick2
2727
outputs: ['clicks:myClick'] // propertyName:alias
2828
})
29-
// #enddocregion my-click-output-2
30-
export class MyClickDirective2 {
29+
// #enddocregion output-myClick2
30+
export class ClickDirective2 {
3131
clicks = new EventEmitter<string>();
3232
toggle = false;
3333

public/docs/_examples/template-syntax/ts/app/my-sizer.component.ts renamed to public/docs/_examples/template-syntax/ts/app/sizer.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
1010
<label [style.font-size.px]="size">FontSize: {{size}}px</label>
1111
</div>`
1212
})
13-
export class MySizerComponent {
13+
export class SizerComponent {
1414
@Input() size: number | string;
1515
@Output() sizeChange = new EventEmitter<number>();
1616

public/docs/ts/latest/guide/template-syntax.jade

+10-10
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ block style-property-name-dart-diff
775775

776776
<a id="eventemitter"></a>
777777
<a id="custom-event"></a>
778-
### Custom events with EventEmitter
778+
### Custom events with *EventEmitter*
779779

780780
Directives typically raise custom events with an Angular [EventEmitter](../api/core/index/EventEmitter-class.html).
781781
The directive creates an `EventEmitter` and exposes it as a property.
@@ -860,33 +860,33 @@ block style-property-name-dart-diff
860860
:marked
861861
The `[(x)]` syntax is easy to demonstrate when the element has a settable property called `x`
862862
and a corresponding event named `xChange`.
863-
Here's a `MySizerComponent` that fits the pattern.
863+
Here's a `SizerComponent` that fits the pattern.
864864
It has a `size` value property and a companion `sizeChange` event:
865865

866-
+makeExample('app/my-sizer.component.ts')
866+
+makeExample('app/sizer.component.ts')
867867

868868
:marked
869869
The initial `size` is an input value from a property binding.
870870
Clicking the buttons increases or decreases the `size`, within min/max values constraints,
871871
and then raises (_emits_) the `sizeChange` event with the adjusted size.
872872

873-
Here's an example in which the `AppComponent.fontSizePx` is two-way bound to the `MySizerComponent`:
873+
Here's an example in which the `AppComponent.fontSizePx` is two-way bound to the `SizerComponent`:
874874

875875
+makeExcerpt('app/app.component.html', 'two-way-1', '')
876876

877877
:marked
878-
The `AppComponent.fontSizePx` establishes the initial `MySizerComponent.size` value.
878+
The `AppComponent.fontSizePx` establishes the initial `SizerComponent.size` value.
879879
Clicking the buttons updates the `AppComponent.fontSizePx` via the two-way binding.
880880
The revised `AppComponent.fontSizePx` value flows through to the _style_ binding, making the displayed text bigger or smaller.
881881
Try it in the <live-example></live-example>.
882882

883883
The two-way binding syntax is really just syntactic sugar for a _property_ binding and an _event_ binding.
884-
Angular _desugars_ the `MySizerComponent` binding into this:
884+
Angular _desugars_ the `SizerComponent` binding into this:
885885

886886
+makeExcerpt('app/app.component.html', 'two-way-2', '')
887887

888888
:marked
889-
The `$event` variable contains the payload of the `MySizerComponent.sizeChange` event.
889+
The `$event` variable contains the payload of the `SizerComponent.sizeChange` event.
890890
Angular assigns the `$event` value to the `AppComponent.fontSizePx` when the user clicks the buttons.
891891

892892
Clearly the two-way binding syntax is a great convenience compared to separate property and event bindings.
@@ -1423,7 +1423,7 @@ h3#aliasing-io Aliasing input/output properties
14231423
Directive consumers expect to bind to the name of the directive.
14241424
For example, when we apply a directive with a `myClick` selector to a `<div>` tag,
14251425
we expect to bind to an event property that is also called `myClick`.
1426-
+makeExample('template-syntax/ts/app/app.component.html', 'my-click')(format=".")
1426+
+makeExample('template-syntax/ts/app/app.component.html', 'myClick')(format=".")
14271427
:marked
14281428
However, the directive name is often a poor choice for the name of a property within the directive class.
14291429
The directive name rarely describes what the property does.
@@ -1436,14 +1436,14 @@ h3#aliasing-io Aliasing input/output properties
14361436

14371437
We can specify the alias for the property name by passing it into the input/output decorator like this:
14381438

1439-
+makeExample('template-syntax/ts/app/my-click.directive.ts', 'my-click-output-1')(format=".")
1439+
+makeExample('template-syntax/ts/app/click.directive.ts', 'output-myClick')(format=".")
14401440

14411441
.l-sub-section
14421442
:marked
14431443
We can also alias property names in the `inputs` and `outputs` #{_array}s.
14441444
We write a colon-delimited (`:`) string with
14451445
the directive property name on the *left* and the public alias on the *right*:
1446-
+makeExample('template-syntax/ts/app/my-click.directive.ts', 'my-click-output-2')(format=".")
1446+
+makeExample('template-syntax/ts/app/click.directive.ts', 'output-myClick2')(format=".")
14471447

14481448
<a id="expression-operators"></a>
14491449
.l-main-section

0 commit comments

Comments
 (0)