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

Commit 0ec8b82

Browse files
committed
post-review changes
1 parent 693f1db commit 0ec8b82

File tree

6 files changed

+96
-74
lines changed

6 files changed

+96
-74
lines changed

public/_includes/_util-fns.jade

+2-2
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ script.
222222
- // E.g. of a project relative path is 'app/main.ts'
223223
- if (ex.title === null || ex.title === undefined) {
224224
- // Title is not given so take it to be ex.filePath.
225-
- // Is title like styles.1.css? Then drop the '.1' qualifier:
226-
- var matches = ex.filePath.match(/^(.*)\.\d(\.\w+)$/);
225+
- // Title like styles.1.css or foo_1.dart? Then drop the '.1' or '_1' qualifier:
226+
- var matches = ex.filePath.match(/^(.*)[\._]\d(\.\w+)$/);
227227
- ex.title = matches ? matches[1] + matches[2] : ex.filePath;
228228
- }
229229
- ex.filePath = getExampleName() + '/' + _docsFor + '/' + ex.filePath;
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
11
// #docplaster
22
// #docregion , v2
33
import 'package:angular2/core.dart';
4+
// #enddocregion ,
5+
// #docregion v2
6+
import 'package:angular2/router.dart';
7+
// #docregion
48

59
import 'hero_service.dart';
610
import 'heroes_component.dart';
711

812
// #enddocregion v2
913
@Component(
10-
selector: 'my-app',
11-
template: '''
14+
selector: 'my-app',
15+
template: '''
1216
<h1>{{title}}</h1>
1317
<my-heroes></my-heroes>''',
14-
directives: const [HeroesComponent],
15-
providers: const [HeroService])
16-
// #enddocregion
18+
directives: const [HeroesComponent],
19+
providers: const [HeroService])
20+
// #enddocregion ,
21+
class Bogus {}
22+
1723
// #docregion v2
1824
@Component(
19-
selector: 'my-app',
20-
// #docregion template-v2
21-
template: '''
25+
selector: 'my-app',
26+
// #docregion template-v2
27+
template: '''
2228
<h1>{{title}}</h1>
2329
<a [routerLink]="['Heroes']">Heroes</a>
2430
<router-outlet></router-outlet>''',
25-
// #enddocregion template-v2
26-
directives: const [HeroesComponent],
27-
providers: const [HeroService])
28-
// #docregion , v2
31+
// #enddocregion template-v2
32+
directives: const [ROUTER_DIRECTIVES],
33+
providers: const [HeroService, ROUTER_PROVIDERS])
34+
@RouteConfig(const [
35+
const Route(path: '/heroes', name: 'Heroes', component: HeroesComponent)
36+
])
37+
// #docregion ,
2938
class AppComponent {
3039
String title = 'Tour of Heroes';
3140
}

public/docs/_examples/toh-5/dart/lib/hero_detail_component.dart

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// #docplaster
22
// #docregion , v2
33
import 'dart:async';
4-
// #docregion goBack
4+
// #docregion dart-html
55
import 'dart:html';
6+
// #enddocregion dart-html
67

7-
// #enddocregion goBack
88
import 'package:angular2/core.dart';
99
// #docregion added-imports
1010
import 'package:angular2/router.dart';
@@ -23,9 +23,9 @@ import 'hero_service.dart';
2323
styleUrls: const ['hero_detail_component.css']
2424
// #docregion v2
2525
)
26-
// #docregion goBack, implement
26+
// #docregion implement
2727
class HeroDetailComponent implements OnInit {
28-
// #enddocregion goBack, implement
28+
// #enddocregion implement
2929
Hero hero;
3030
// #docregion ctor
3131
final HeroService _heroService;
@@ -41,9 +41,10 @@ class HeroDetailComponent implements OnInit {
4141
if (id != null) hero = await (_heroService.getHero(id));
4242
}
4343
// #enddocregion ngOnInit
44-
// #docregion goBack
4544

45+
// #docregion goBack
4646
void goBack() {
4747
window.history.back();
4848
}
49+
// #enddocregion goBack
4950
}

public/docs/dart/latest/tutorial/toh-pt5.jade

+12-6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ block intro-file-tree
2929
block keep-app-running
3030
:marked
3131
### Keep the app compiling and running
32+
3233
Open a terminal/console window.
3334
Start the Dart compiler, watch for changes, and start our server by entering the command:
3435

@@ -71,7 +72,7 @@ block router-config-intro
7172
The `AppComponent` doesn't have a router yet. We'll use the `@RouteConfig`
7273
annotation to simultaneously:
7374

74-
- Assign a router to the component and
75+
- Assign a router to the component
7576
- Configure that router with *routes*
7677

7778
block routerLink
@@ -96,17 +97,16 @@ block redirect-vs-use-as-default
9697

9798
block templateUrl-path-resolution
9899
:marked
99-
The given path must resolve to the named [asset][] within the
100-
application's package. Assests from other packages can also be accessed
101-
by providing a full package reference, such as
102-
`'package:some_other_package/dashboard_component.html'`.
100+
The value of `templateUrl` can be an [asset][] in this package or another
101+
package. To use an asset in another package, use a full package reference,
102+
such as `'package:some_other_package/dashboard_component.html'`.
103103

104104
[asset]: https://www.dartlang.org/tools/pub/glossary#asset
105105

106106
block route-params
107107
:marked
108108
We will no longer receive the hero in a parent component property binding.
109-
The new `HeroDetailComponent` should take the `id` parameter from the router's
109+
The new `HeroDetailComponent` should take the `id` parameter from the router's
110110
`RouteParams` service and use the `HeroService` to fetch the hero with that `id`.
111111

112112
block ngOnInit
@@ -118,6 +118,12 @@ block extract-id
118118
:marked
119119
Notice how we extract the `id` by calling the `RouteParams.get` method.
120120

121+
block dart-html
122+
:marked
123+
We'll also need to import `dart:html` to gain access to `window`.
124+
125+
+makeExcerpt('lib/hero_detail_component.dart', 'dart-html', '')
126+
121127
block heroes-component-cleanup
122128
:marked
123129
Because the template for `HeroesComponent` no longer uses `HeroDetailComponent`

public/docs/ts/_cache/tutorial/toh-pt5.jade

+28-25
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ figure.image-display
4646
:marked
4747
## Where We Left Off
4848

49-
Before we continue with our Tour of Heroes, let’s verify that
49+
Before we continue with our Tour of Heroes, let’s verify that
5050
we have the following structure after adding our hero service
5151
and hero detail component. If not, we’ll need to go back and follow the previous chapters.
5252

@@ -105,7 +105,7 @@ block keep-app-running
105105

106106
Our current app loads `AppComponent` and immediately displays the list of heroes.
107107

108-
Our revised app should present a shell with a choice of views (*Dashboard* and *Heroes*)
108+
Our revised app should present a shell with a choice of views (*Dashboard* and *Heroes*)
109109
and then default to one of them.
110110

111111
The `AppComponent` should only handle navigation.
@@ -135,9 +135,9 @@ block keep-app-running
135135
* Create the file <span ngio-ex>app/app.component.ts</span>.
136136
* Define an <span if-docs="ts">exported</span> `AppComponent` class.
137137
* Add an `@Component` !{_decorator} above the class with a `my-app` selector.
138-
* Move from `HeroesComponent` to `AppComponent` the
139-
* `title` class property, and
140-
* `@Component` template `<h1>` element containing a `title` binding.
138+
* Move the following from `HeroesComponent` to `AppComponent`:
139+
* `title` class property
140+
* `@Component` template `<h1>` element, which contains a binding to `title`
141141
* Add a `<my-heroes>` element to the app template just below the heading so we still see the heroes.
142142
* Add `HeroesComponent` to the `!{_declsVsDirectives}` !{_array} of `!{_AppModuleVsAppComp}` so Angular recognizes the `<my-heroes>` tags.
143143
* Add `HeroService` to the `providers` !{_array} of `!{_AppModuleVsAppComp}` because we'll need it in every other view.
@@ -171,8 +171,8 @@ block app-comp-v1
171171
block angular-router
172172
:marked
173173
The Angular router is an external, optional Angular NgModule called `RouterModule`.
174-
The router is a combination of multiple provided services (`RouterModule`),
175-
multiple directives (`RouterOutlet, RouterLink, RouterLinkActive`),
174+
The router is a combination of multiple provided services (`RouterModule`),
175+
multiple directives (`RouterOutlet, RouterLink, RouterLinkActive`),
176176
and a configuration (`Routes`). We'll configure our routes first.
177177

178178
:marked
@@ -185,7 +185,7 @@ block angular-router
185185
.callout.is-important
186186
header base href is essential
187187
:marked
188-
See the *base href* section of the [Router](../guide/router.html#!#base-href)
188+
See the *base href* section of the [Router](../guide/router.html#!#base-href)
189189
chapter to learn why this matters.
190190

191191
a#configure-routes
@@ -213,7 +213,7 @@ block router-config-intro
213213
This *route definition* has the following parts:
214214

215215
- **path**: the router matches this route's path to the URL in the browser address bar (`/heroes`).
216-
<li if-docs="dart"> **name**: the official name of the route;
216+
<li if-docs="dart"> **name**: the official name of the route;
217217
it *must* begin with a capital letter to avoid confusion with the *path* (`Heroes`).</li>
218218
- **component**: the component that the router should create when navigating to this route (`HeroesComponent`).
219219

@@ -315,7 +315,7 @@ block routerLink
315315

316316
Go back to `!{_appRoutingTsVsAppComp}` and teach it to navigate to the dashboard.
317317

318-
Import `DashboardComponent` and
318+
Import the dashboard component and
319319
add the following route definition to the `!{_RoutesVsAtRouteConfig}` !{_array} of definitions.
320320

321321
- var _file = _docsFor == 'dart' ? 'lib/app_component.dart' : 'app/app.routing.ts'
@@ -346,6 +346,8 @@ block redirect-vs-use-as-default
346346
Learn about the *redirects* in the [Routing](../guide/router.html#!#redirect) chapter.
347347

348348
:marked
349+
#### Add navigation to the template
350+
349351
Finally, add a dashboard navigation link to the template, just above the *Heroes* link.
350352

351353
- var _vers = _docsFor == 'dart' ? '' : '.1'
@@ -443,7 +445,7 @@ block redirect-vs-use-as-default
443445
The new route is a bit unusual in that we must tell the `HeroDetailComponent` *which hero to show*.
444446
We didn't have to tell the `HeroesComponent` or the `DashboardComponent` anything.
445447

446-
At the moment the parent `HeroesComponent` sets the component's `hero` property to a
448+
At the moment the parent `HeroesComponent` sets the component's `hero` property to a
447449
hero object with a binding like this.
448450

449451
code-example(language="html").
@@ -455,7 +457,7 @@ code-example(language="html").
455457

456458
### Parameterized route
457459

458-
We *can* add the hero's `id` to the URL. When routing to the hero whose `id` is 11,
460+
We *can* add the hero's `id` to the URL. When routing to the hero whose `id` is 11,
459461
we could expect to see an URL such as this:
460462

461463
code-example(format='').
@@ -475,9 +477,10 @@ code-example(format='').
475477
:marked
476478
The colon (:) in the path indicates that `:id` is a placeholder to be filled with a specific hero `id`
477479
when navigating to the `HeroDetailComponent`.
480+
478481
.l-sub-section
479482
:marked
480-
Remember to import `HeroDetailComponent` before creating this route.
483+
Remember to import the hero detail component before creating this route.
481484

482485
+ifDocsFor('ts|js')
483486
:marked
@@ -517,15 +520,15 @@ block route-params
517520
in the `ActivatedRoute` service and use the `HeroService` to fetch the hero with that `id`.
518521

519522
:marked
520-
Add requisite imports first:
523+
First, add the requisite imports:
521524

522525
- var _vers = _docsFor == 'dart' ? '' : '.1'
523526
+makeExcerpt('app/hero-detail.component' + _vers + '.ts', 'added-imports', '')
524527

525528
- var _ActivatedRoute = _docsFor == 'dart' ? 'RouteParams' : 'ActivatedRoute'
526529
:marked
527530
Let's have the `!{_ActivatedRoute}` service and the `HeroService` injected
528-
into the constructor with their values saved in private fields:
531+
into the constructor, saving their values in private fields:
529532

530533
+makeExcerpt('app/hero-detail.component.ts (constructor)', 'ctor')
531534

@@ -574,6 +577,9 @@ block extract-id
574577

575578
+makeExcerpt('app/hero-detail.component.ts', 'goBack')
576579

580+
block dart-html
581+
//- N/A
582+
577583
- var _CanDeactivateGuard = _docsFor == 'dart' ? '<em>routerCanDeactivate</em> hook' : '<em>CanDeactivate</em> guard'
578584
- var _CanDeactivateGuardUri = _docsFor == 'dart' ? 'angular2.router/CanDeactivate-class' : 'router/index/CanDeactivate-interface'
579585
.l-sub-section
@@ -589,8 +595,9 @@ block extract-id
589595
+makeExcerpt('app/hero-detail.component.html', 'back-button', '')
590596

591597
:marked
592-
Modifing the template to add this button spurs us to take one more
593-
incremental improvement and migrate the template to its own file:
598+
Modifing the template to add this button spurs us to take one more
599+
incremental improvement and migrate the template to its own file,
600+
called <span ngio-ex>hero-detail.component.html</span>:
594601

595602
+makeExcerpt('app/hero-detail.component.html')
596603

@@ -601,10 +608,6 @@ block extract-id
601608

602609
:marked
603610
Refresh the browser and see the results.
604-
Here's the (nearly) finished `HeroDetailComponent` but without the `@Input` !{_decorator} on `hero`
605-
&mdash; we'll be cleaning that out soon:
606-
607-
+makeExcerpt('app/hero-detail.component.ts', 'v2')
608611

609612
.l-main-section
610613
:marked
@@ -725,7 +728,7 @@ figure.image-display
725728
:marked
726729
The `styleUrls` property is !{_an} !{_array} of style file names (with paths).
727730
We could list multiple style files from different locations if we needed them.
728-
<span if-docs="ts">As with `templateUrl`, we must specify the path _all the way
731+
<span if-docs="ts">As with `templateUrl`, we must specify the path _all the way
729732
back to the application root_.</span>
730733

731734
block heroes-component-cleanup
@@ -777,10 +780,10 @@ block heroes-component-cleanup
777780

778781
:marked
779782
### Stylish Hero Details
780-
783+
781784
The designers also gave us CSS styles specifically for the `HeroDetailComponent`.
782785

783-
Add a <span ngio-ex>hero-detail.component.css</span> to the `!{_appDir}`
786+
Add a <span ngio-ex>hero-detail.component.css</span> to the `!{_appDir}`
784787
folder and refer to that file inside
785788
the `styleUrls` !{_array} as we did for `DashboardComponent`.
786789
Let's also remove the `hero` property `@Input` !{_decorator}
@@ -891,7 +894,7 @@ block file-tree-end
891894
.file index.html
892895
.file package.json
893896
.file styles.css
894-
.file systemjs.config.json
897+
.file systemjs.config.js
895898
.file tsconfig.json
896899
.file typings.json
897900

0 commit comments

Comments
 (0)