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

Commit c32800b

Browse files
committed
minor edits to TS jade
1 parent 1f70d2b commit c32800b

File tree

1 file changed

+60
-48
lines changed

1 file changed

+60
-48
lines changed

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

+60-48
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ block router-config-intro
205205

206206
- var _are = _docsFor == 'dart' ? 'takes' : 'are'
207207
- var _routePathPrefix = _docsFor == 'dart' ? '/' : ''
208-
209208
:marked
210209
The `!{_RoutesVsAtRouteConfig}` !{_are} !{_an} !{_array} of *route definitions*.
211210
We have only one route definition at the moment but rest assured, we'll add more.
@@ -362,11 +361,15 @@ block redirect-vs-use-as-default
362361

363362
Replace the `template` metadata with a `templateUrl` property that points to a new
364363
template file.
365-
366-
Set the `moduleId` property to `module.id` for module-relative loading of the `templateUrl`.
364+
+ifDocsFor('ts|js')
365+
:marked
366+
Set the `moduleId` property to `module.id` for module-relative loading of the `templateUrl`.
367367

368368
+makeExcerpt('app/dashboard.component.ts', 'metadata')
369369

370+
block templateUrl-path-resolution
371+
//- N/A for TS
372+
370373
:marked
371374
Create that file with this content:
372375

@@ -404,7 +407,7 @@ block redirect-vs-use-as-default
404407
* Inject the `HeroService` in the constructor and hold it in a private `!{_priv}heroService` field.
405408
* Call the service to get heroes inside the Angular `ngOnInit` lifecycle hook.
406409

407-
In this dashboard we cherry-pick four heroes (2nd, 3rd, 4th, and 5th) with the `Array.slice` method.
410+
In this dashboard we cherry-pick four heroes (2nd, 3rd, 4th, and 5th)<span if-docs="ts"> with the `Array.slice` method</span>.
408411

409412
Refresh the browser and see four heroes in the new dashboard.
410413

@@ -575,10 +578,10 @@ block extract-id
575578
incremental improvement and migrate the template to its own file,
576579
called <span ngio-ex>hero-detail.component.html</span>:
577580

578-
+makeExample('app/hero-detail.component.html')(format='.')
581+
+makeExample('app/hero-detail.component.html')
579582

580583
:marked
581-
We update the component metadata with a `moduleId` and a `templateUrl` pointing to the template file that we just created.
584+
We update the component metadata with a <span if-docs="ts">`moduleId` and a </span>`templateUrl` pointing to the template file that we just created.
582585

583586
+makeExcerpt('app/hero-detail.component.ts', 'metadata')
584587

@@ -600,11 +603,17 @@ block extract-id
600603

601604
+makeExample('app/dashboard.component.html', 'click', 'app/dashboard.component.html (repeated <a> tag)')
602605

606+
+ifDocsFor('dart')
607+
.alert.is-important
608+
:marked
609+
Router links in the dashboard are currently not operational, as reported in issue
610+
[dart-lang/angular2/issues/186](https://github.com/dart-lang/angular2/issues/186).
611+
603612
- var _pathVsName = _docsFor == 'dart' ? 'name' : 'path'
604613
:marked
605614
Notice the `[routerLink]` binding.
606615

607-
In the top level navigation in the [`AppComponent`
616+
Top level navigation in the [`AppComponent`
608617
template](#router-links) has router links set to fixed !{_pathVsName}s of the
609618
destination routes, "/dashboard" and "/heroes".
610619

@@ -622,53 +631,55 @@ block extract-id
622631
:marked
623632
Refresh the browser and select a hero from the dashboard; the app should navigate directly to that hero’s details.
624633

625-
.l-main-section
626-
:marked
627-
## Refactor routes to a _Routing Module_
634+
+ifDocsFor('ts')
635+
.l-main-section
636+
:marked
637+
## Refactor routes to a _Routing Module_
628638

629-
Almost 20 lines of `AppModule` are devoted to configuring four routes.
630-
Most application have many more routes and they [add guard services](../guide/router.html#guards)
631-
to protect against unwanted or unauthorized navigations.
632-
Routing considerations could quickly dominate this module and obscure its primary purpose which is to
633-
establish key facts about the entire app for the Angular compiler.
639+
Almost 20 lines of `AppModule` are devoted to configuring four routes.
640+
Most applications have many more routes and they [add guard services](../guide/router.html#guards)
641+
to protect against unwanted or unauthorized navigations.
642+
Routing considerations could quickly dominate this module and obscure its primary purpose which is to
643+
establish key facts about the entire app for the Angular compiler.
634644

635-
We should refactor the routing configuration into its own class.
636-
What kind of class?
637-
The current `RouterModule.forRoot()` produces an Angular `ModuleWithProviders` which suggests that a
638-
class dedicated to routing should be some kind of module.
639-
It should be a [_Routing Module_](../guide/router.html#routing-module).
645+
We should refactor the routing configuration into its own class.
646+
What kind of class?
647+
The current `RouterModule.forRoot()` produces an Angular `ModuleWithProviders` which suggests that a
648+
class dedicated to routing should be some kind of module.
649+
It should be a [_Routing Module_](../guide/router.html#routing-module).
640650

641-
By convention the name of a _Routing Module_ contains the word "Routing" and
642-
aligns with the name of the module that declares the components navigated to".
643-
644-
Create an `app-routing.module.ts` file as a sibling to `app.module.ts`. Give it the following contents extracted from the `AppModule` class:
651+
By convention the name of a _Routing Module_ contains the word "Routing" and
652+
aligns with the name of the module that declares the components navigated to.
645653

646-
+makeExample('app/app-routing.module.ts')
647-
:marked
648-
Noteworthy points, typical of _Routing Modules_:
649-
* Pull the routes into a variable. You might export it in future and it clarifies the _Routing Module_ pattern.
654+
Create an `app-routing.module.ts` file as a sibling to `app.module.ts`. Give it the following contents extracted from the `AppModule` class:
650655

651-
* Add `RouterModule.forRoot(routes)` to `imports`.
652-
653-
* Add `RouterModule` to `exports` so that the components in the companion module have access to Router declarables
654-
such as `RouterLink` and `RouterOutlet`.
655-
656-
* No `declarations`! Declarations are the responsibility of the companion module.
656+
+makeExample('app/app-routing.module.ts')
657+
:marked
658+
Noteworthy points, typical of _Routing Modules_:
659+
* Pull the routes into a variable. You might export it in future and it clarifies the _Routing Module_ pattern.
657660

658-
* Add module `providers` for guard services if you have them; there are none in this example.
661+
* Add `RouterModule.forRoot(routes)` to `imports`.
659662

660-
### Update _AppModule_
663+
* Add `RouterModule` to `exports` so that the components in the companion module have access to Router declarables
664+
such as `RouterLink` and `RouterOutlet`.
661665

662-
Now delete the routing configuration from `AppModule` and import the `AppRoutingModule`
663-
(_both_ with an ES `import` statement _and_ by adding it to the `NgModule.imports` list).
666+
* No `declarations`! Declarations are the responsibility of the companion module.
667+
668+
* Add module `providers` for guard services if you have them; there are none in this example.
669+
670+
### Update _AppModule_
671+
672+
Now delete the routing configuration from `AppModule` and import the `AppRoutingModule`
673+
(_both_ with an ES `import` statement _and_ by adding it to the `NgModule.imports` list).
674+
675+
Here is the revised `AppModule`, compared to its pre-refactor state:
676+
+makeTabs(
677+
`toh-5/ts/app/app.module.ts, toh-5/ts/app/app.module.3.ts`,
678+
null,
679+
`app/app.module.ts (after), app/app.module.ts (before)`)
680+
:marked
681+
It's simpler and focused on indentifying the key pieces of the application.
664682

665-
Here is the revised `AppModule`, compared to its pre-refactor state:
666-
+makeTabs(
667-
`toh-5/ts/app/app.module.ts, toh-5/ts/app/app.module.3.ts`,
668-
null,
669-
`app/app.module.ts (after), app/app.module.ts (before)`)
670-
:marked
671-
It's simpler and focused on indentifying the key pieces of the application.
672683
.l-main-section
673684
:marked
674685
## Select a Hero in the *HeroesComponent*
@@ -738,7 +749,7 @@ figure.image-display
738749
1. *Cut-and-paste* the template contents into a new <span ngio-ex>heroes.component.html</span> file.
739750
1. *Cut-and-paste* the styles contents into a new <span ngio-ex>heroes.component.css</span> file.
740751
1. *Set* the component metadata's `templateUrl` and `styleUrls` properties to refer to both files.
741-
1. *Set* the `moduleId` property to `module.id` so that `templateUrl` and `styleUrls` are relative to the component.
752+
<li if-docs="ts">. *Set* the `moduleId` property to `module.id` so that `templateUrl` and `styleUrls` are relative to the component.</li>
742753

743754
.l-sub-section
744755
:marked
@@ -764,11 +775,12 @@ block heroes-component-cleanup
764775
1. Implement `gotoDetail` by calling the `router.navigate` method
765776

766777
+makeExcerpt('app/heroes.component.ts', 'gotoDetail')
778+
767779
:marked
768780
Note that we're passing a two-element **link parameters !{_array}**
769781
&mdash; a path and the route parameter &mdash; to
770782
the `router.navigate` method just as we did in the `[routerLink]` binding
771-
back in the `DashboardComponent`
783+
back in the `DashboardComponent`.
772784
Here's the fully revised `HeroesComponent` class:
773785

774786
+makeExcerpt('app/heroes.component.ts', 'class')
@@ -934,7 +946,7 @@ block file-tree-end
934946
- We shared the `HeroService` among multiple components.
935947
- We moved HTML and CSS out of the component file and into their own files.
936948
- We added the `uppercase` pipe to format data.
937-
- We refactored routes into a `Routing Module` that we import.
949+
<li if-docs="ts"> We refactored routes into a `Routing Module` that we import.</li>
938950

939951
### The Road Ahead
940952

0 commit comments

Comments
 (0)