docs(toh): fix code-example format and Dart code excerpt (#2907)
* ensure HeroesComponent renaming doesn't show router * use code-example format consistent with the rest of the docs
This commit is contained in:
parent
4fe2410e01
commit
c7717b4850
@ -26,7 +26,11 @@ class HeroesComponent implements OnInit {
|
|||||||
Hero selectedHero;
|
Hero selectedHero;
|
||||||
|
|
||||||
// #docregion renaming
|
// #docregion renaming
|
||||||
HeroesComponent(this._heroService, this._router);
|
HeroesComponent(this._heroService,
|
||||||
|
// #enddocregion renaming
|
||||||
|
this._router
|
||||||
|
// #docregion renaming
|
||||||
|
);
|
||||||
// #enddocregion renaming
|
// #enddocregion renaming
|
||||||
|
|
||||||
Future<Null> getHeroes() async {
|
Future<Null> getHeroes() async {
|
||||||
|
@ -38,7 +38,7 @@ include ../_util-fns
|
|||||||
## Keep the app compiling and running
|
## Keep the app compiling and running
|
||||||
We want to start the Dart compiler, have it watch for changes, and start our server. We'll do this by typing
|
We want to start the Dart compiler, have it watch for changes, and start our server. We'll do this by typing
|
||||||
|
|
||||||
code-example(language="bash").
|
code-example(language="sh" class="code-shell").
|
||||||
pub serve
|
pub serve
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
|
@ -34,7 +34,7 @@ include ../_util-fns
|
|||||||
### Keep the app compiling and running
|
### Keep the app compiling and running
|
||||||
We want to start the Dart compiler, have it watch for changes, and start our server. We'll do this by typing
|
We want to start the Dart compiler, have it watch for changes, and start our server. We'll do this by typing
|
||||||
|
|
||||||
code-example(language="bash").
|
code-example(language="sh" class="code-shell").
|
||||||
pub serve
|
pub serve
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
@ -157,7 +157,7 @@ code-example(language="bash").
|
|||||||
|
|
||||||
:marked
|
:marked
|
||||||
Focus on the event binding
|
Focus on the event binding
|
||||||
code-example(format="." language="bash").
|
code-example.
|
||||||
(click)="onSelect(hero)"
|
(click)="onSelect(hero)"
|
||||||
:marked
|
:marked
|
||||||
The parentheses identify the `<li>` element’s `click` event as the target.
|
The parentheses identify the `<li>` element’s `click` event as the target.
|
||||||
@ -204,7 +204,7 @@ code-example(language="bash").
|
|||||||
The `selectedHero` is `undefined`.
|
The `selectedHero` is `undefined`.
|
||||||
That’s why we'll see the following error in the browser’s console:
|
That’s why we'll see the following error in the browser’s console:
|
||||||
|
|
||||||
code-example(language="html").
|
code-example(format="nocode").
|
||||||
EXCEPTION: TypeError: Cannot read property 'name' of undefined in [null]
|
EXCEPTION: TypeError: Cannot read property 'name' of undefined in [null]
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
|
@ -27,7 +27,7 @@ include ../_util-fns
|
|||||||
### Keep the app compiling and running
|
### Keep the app compiling and running
|
||||||
We want to start the Dart compiler, have it watch for changes, and start our server. We'll do this by typing
|
We want to start the Dart compiler, have it watch for changes, and start our server. We'll do this by typing
|
||||||
|
|
||||||
code-example(language="bash").
|
code-example(language="sh" class="code-shell").
|
||||||
pub serve
|
pub serve
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
@ -122,7 +122,7 @@ code-example(language="bash").
|
|||||||
|
|
||||||
We will soon update the `AppComponent` template so that it binds its `selectedHero` property
|
We will soon update the `AppComponent` template so that it binds its `selectedHero` property
|
||||||
to the `hero` property of our `HeroDetailComponent`. The binding *might* look like this:
|
to the `hero` property of our `HeroDetailComponent`. The binding *might* look like this:
|
||||||
code-example(format=".").
|
code-example(language="html").
|
||||||
<my-hero-detail [hero]="selectedHero"></my-hero-detail>
|
<my-hero-detail [hero]="selectedHero"></my-hero-detail>
|
||||||
:marked
|
:marked
|
||||||
Notice that the `hero` property is the ***target*** of a property binding — it's in square brackets to the left of the (=).
|
Notice that the `hero` property is the ***target*** of a property binding — it's in square brackets to the left of the (=).
|
||||||
@ -156,7 +156,7 @@ code-example(format=".").
|
|||||||
:marked
|
:marked
|
||||||
Find the location in the template where we removed the *Hero Detail* content
|
Find the location in the template where we removed the *Hero Detail* content
|
||||||
and add an element tag that represents the `HeroDetailComponent`.
|
and add an element tag that represents the `HeroDetailComponent`.
|
||||||
code-example(format=".").
|
code-example(language="html").
|
||||||
<my-hero-detail></my-hero-detail>
|
<my-hero-detail></my-hero-detail>
|
||||||
.l-sub-section
|
.l-sub-section
|
||||||
:marked
|
:marked
|
||||||
@ -164,7 +164,7 @@ code-example(format=".").
|
|||||||
:marked
|
:marked
|
||||||
The two components won't coordinate until we bind the `selectedHero` property of the `AppComponent`
|
The two components won't coordinate until we bind the `selectedHero` property of the `AppComponent`
|
||||||
to the `HeroDetailComponent` element's `hero` property like this:
|
to the `HeroDetailComponent` element's `hero` property like this:
|
||||||
code-example(format=".").
|
code-example(language="html").
|
||||||
<my-hero-detail [hero]="selectedHero"></my-hero-detail>
|
<my-hero-detail [hero]="selectedHero"></my-hero-detail>
|
||||||
:marked
|
:marked
|
||||||
The `AppComponent`’s template should now look like this
|
The `AppComponent`’s template should now look like this
|
||||||
|
@ -41,7 +41,7 @@ include ../_util-fns
|
|||||||
Open a terminal/console window.
|
Open a terminal/console window.
|
||||||
Start the Dart compiler, watch for changes, and start our server by entering the command:
|
Start the Dart compiler, watch for changes, and start our server by entering the command:
|
||||||
|
|
||||||
code-example(language="bash").
|
code-example(language="sh" class="code-shell").
|
||||||
pub serve
|
pub serve
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
|
@ -32,7 +32,7 @@ block keep-app-running
|
|||||||
Open a terminal/console window.
|
Open a terminal/console window.
|
||||||
Start the Dart compiler, watch for changes, and start our server by entering the command:
|
Start the Dart compiler, watch for changes, and start our server by entering the command:
|
||||||
|
|
||||||
code-example(language="bash").
|
code-example(language="sh" class="code-shell").
|
||||||
pub serve
|
pub serve
|
||||||
|
|
||||||
block app-comp-v1
|
block app-comp-v1
|
||||||
|
@ -16,7 +16,7 @@ block start-server-and-watch
|
|||||||
Open a terminal/console window.
|
Open a terminal/console window.
|
||||||
Start the Dart compiler, watch for changes, and start our server by entering the command:
|
Start the Dart compiler, watch for changes, and start our server by entering the command:
|
||||||
|
|
||||||
code-example(language="bash").
|
code-example(language="sh" class="code-shell").
|
||||||
pub serve
|
pub serve
|
||||||
|
|
||||||
block http-library
|
block http-library
|
||||||
|
@ -69,7 +69,7 @@ block keep-app-running
|
|||||||
Open a terminal/console window and enter the following command to
|
Open a terminal/console window and enter the following command to
|
||||||
start the TypeScript compiler, start the server, and watch for changes:
|
start the TypeScript compiler, start the server, and watch for changes:
|
||||||
|
|
||||||
code-example(language="bash").
|
code-example(language="sh" class="code-shell").
|
||||||
npm start
|
npm start
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
@ -438,7 +438,7 @@ code-example(language="html").
|
|||||||
We *can* add the hero's `id` to the URL. When routing to the hero whose `id` is 11,
|
We *can* add the hero's `id` to the URL. When routing to the hero whose `id` is 11,
|
||||||
we could expect to see an URL such as this:
|
we could expect to see an URL such as this:
|
||||||
|
|
||||||
code-example(format='').
|
code-example(format="nocode").
|
||||||
/detail/11
|
/detail/11
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
|
@ -34,7 +34,7 @@ block start-server-and-watch
|
|||||||
Open a terminal/console window and enter the following command to
|
Open a terminal/console window and enter the following command to
|
||||||
start the TypeScript compiler, start the server, and watch for changes:
|
start the TypeScript compiler, start the server, and watch for changes:
|
||||||
|
|
||||||
code-example(language="bash").
|
code-example(language="sh" class="code-shell").
|
||||||
npm start
|
npm start
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
|
@ -36,7 +36,7 @@ include ../_util-fns
|
|||||||
### Keep the app transpiling and running
|
### Keep the app transpiling and running
|
||||||
We want to start the TypeScript compiler, have it watch for changes, and start our server. We'll do this by typing
|
We want to start the TypeScript compiler, have it watch for changes, and start our server. We'll do this by typing
|
||||||
|
|
||||||
code-example(language="bash").
|
code-example(language="sh" class="code-shell").
|
||||||
npm start
|
npm start
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
@ -161,7 +161,7 @@ code-example(language="bash").
|
|||||||
|
|
||||||
:marked
|
:marked
|
||||||
Focus on the event binding
|
Focus on the event binding
|
||||||
code-example(format="." language="bash").
|
code-example.
|
||||||
(click)="onSelect(hero)"
|
(click)="onSelect(hero)"
|
||||||
:marked
|
:marked
|
||||||
The parenthesis identify the `<li>` element’s `click` event as the target.
|
The parenthesis identify the `<li>` element’s `click` event as the target.
|
||||||
@ -209,7 +209,7 @@ code-example(language="bash").
|
|||||||
The `selectedHero` is `undefined`.
|
The `selectedHero` is `undefined`.
|
||||||
That’s why we'll see the following error in the browser’s console:
|
That’s why we'll see the following error in the browser’s console:
|
||||||
|
|
||||||
code-example(language="html").
|
code-example(format="nocode").
|
||||||
EXCEPTION: TypeError: Cannot read property 'name' of undefined in [null]
|
EXCEPTION: TypeError: Cannot read property 'name' of undefined in [null]
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
|
@ -29,7 +29,7 @@ include ../_util-fns
|
|||||||
### Keep the app transpiling and running
|
### Keep the app transpiling and running
|
||||||
We want to start the TypeScript compiler, have it watch for changes, and start our server. We'll do this by typing
|
We want to start the TypeScript compiler, have it watch for changes, and start our server. We'll do this by typing
|
||||||
|
|
||||||
code-example(language="bash").
|
code-example(language="sh" class="code-shell").
|
||||||
npm start
|
npm start
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
@ -124,7 +124,7 @@ code-example(language="bash").
|
|||||||
|
|
||||||
We will soon update the `AppComponent` template so that it binds its `selectedHero` property
|
We will soon update the `AppComponent` template so that it binds its `selectedHero` property
|
||||||
to the `hero` property of our `HeroDetailComponent`. The binding *might* look like this:
|
to the `hero` property of our `HeroDetailComponent`. The binding *might* look like this:
|
||||||
code-example(format=".").
|
code-example(language="html").
|
||||||
<my-hero-detail [hero]="selectedHero"></my-hero-detail>
|
<my-hero-detail [hero]="selectedHero"></my-hero-detail>
|
||||||
:marked
|
:marked
|
||||||
Notice that the `hero` property is the ***target*** of a property binding — it's in square brackets to the left of the (=).
|
Notice that the `hero` property is the ***target*** of a property binding — it's in square brackets to the left of the (=).
|
||||||
@ -169,7 +169,7 @@ code-example(format=".").
|
|||||||
Now that the application knows about our `HeroDetailComponent`,
|
Now that the application knows about our `HeroDetailComponent`,
|
||||||
find the location in the `AppComponent` template where we removed the *Hero Detail* content
|
find the location in the `AppComponent` template where we removed the *Hero Detail* content
|
||||||
and add an element tag that represents the `HeroDetailComponent`.
|
and add an element tag that represents the `HeroDetailComponent`.
|
||||||
code-example(format=".").
|
code-example(language="html").
|
||||||
<my-hero-detail></my-hero-detail>
|
<my-hero-detail></my-hero-detail>
|
||||||
.l-sub-section
|
.l-sub-section
|
||||||
:marked
|
:marked
|
||||||
@ -177,7 +177,7 @@ code-example(format=".").
|
|||||||
:marked
|
:marked
|
||||||
The two components won't coordinate until we bind the `selectedHero` property of the `AppComponent`
|
The two components won't coordinate until we bind the `selectedHero` property of the `AppComponent`
|
||||||
to the `HeroDetailComponent` element's `hero` property like this:
|
to the `HeroDetailComponent` element's `hero` property like this:
|
||||||
code-example(format=".")
|
code-example(language="html").
|
||||||
<my-hero-detail [hero]="selectedHero"></my-hero-detail>
|
<my-hero-detail [hero]="selectedHero"></my-hero-detail>
|
||||||
:marked
|
:marked
|
||||||
The `AppComponent`’s template should now look like this
|
The `AppComponent`’s template should now look like this
|
||||||
|
@ -44,7 +44,7 @@ include ../_util-fns
|
|||||||
Open a terminal/console window.
|
Open a terminal/console window.
|
||||||
Start the TypeScript compiler, watch for changes, and start our server by entering the command:
|
Start the TypeScript compiler, watch for changes, and start our server by entering the command:
|
||||||
|
|
||||||
code-example(language="bash").
|
code-example(language="sh" class="code-shell").
|
||||||
npm start
|
npm start
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
|
@ -69,7 +69,7 @@ block keep-app-running
|
|||||||
Open a terminal/console window and enter the following command to
|
Open a terminal/console window and enter the following command to
|
||||||
start the TypeScript compiler, start the server, and watch for changes:
|
start the TypeScript compiler, start the server, and watch for changes:
|
||||||
|
|
||||||
code-example(language="bash").
|
code-example(language="sh" class="code-shell").
|
||||||
npm start
|
npm start
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
@ -438,7 +438,7 @@ code-example(language="html").
|
|||||||
We *can* add the hero's `id` to the URL. When routing to the hero whose `id` is 11,
|
We *can* add the hero's `id` to the URL. When routing to the hero whose `id` is 11,
|
||||||
we could expect to see an URL such as this:
|
we could expect to see an URL such as this:
|
||||||
|
|
||||||
code-example(format='').
|
code-example(format="nocode").
|
||||||
/detail/11
|
/detail/11
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
|
@ -34,7 +34,7 @@ block start-server-and-watch
|
|||||||
Open a terminal/console window and enter the following command to
|
Open a terminal/console window and enter the following command to
|
||||||
start the TypeScript compiler, start the server, and watch for changes:
|
start the TypeScript compiler, start the server, and watch for changes:
|
||||||
|
|
||||||
code-example(language="bash").
|
code-example(language="sh" class="code-shell").
|
||||||
npm start
|
npm start
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
|
Loading…
x
Reference in New Issue
Block a user