Skip to content

Commit c52f4bb

Browse files
committed
docs(toh-5): review and update/resync Dart
**NOTE: run `gulp add-example-boilerplate` after pulling in the commit.** This is preparatory work for angular#2035. As part of the the chapter review, the Dart .jade was enhanced to use Jade extends (angular#2018). By the same token it contributed to a post-RC5 resync (angular#2077). Other key changes: Dart and TS code: - Eliminated `styles.1.css` in favor of docregions in `styles.css`. - `docregion` tags renamed in a few places. - **No other code changes**. TS prose - Fixed: misnamed variable `routing` -> `appRoutes`. - All other changes are **minor copy edits**, or changes to support Dart via Jade extends. Diff of generated HTML for TS chapter was inspected to ensure only minor copy edits prevailed (i.e., that the support for Jade extends had no impact on the generated HTML).
1 parent 9869bf5 commit c52f4bb

16 files changed

+915
-1217
lines changed

public/docs/_examples/styles.css

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* #docregion , quickstart */
1+
/* #docregion , quickstart, toh */
22
/* Master Styles */
33
h1 {
44
color: #369;
@@ -18,6 +18,7 @@ body, input[text], button {
1818
color: #888;
1919
font-family: Cambria, Georgia;
2020
}
21+
/* #enddocregion toh */
2122
a {
2223
cursor: pointer;
2324
cursor: hand;
@@ -137,7 +138,7 @@ nav a.active {
137138
margin-right: .8em;
138139
border-radius: 4px 0 0 4px;
139140
}
140-
141+
/* #docregion toh */
141142
/* everywhere else */
142143
* {
143144
font-family: Arial, Helvetica, sans-serif;

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import 'package:angular2_tour_of_heroes/hero_detail_component.dart';
2121
</nav>
2222
<router-outlet></router-outlet>''',
2323
// #enddocregion template
24-
// #docregion style-urls
24+
// #docregion styleUrls
2525
styleUrls: const ['app_component.css'],
26-
// #enddocregion style-urls
26+
// #enddocregion styleUrls
2727
directives: const [ROUTER_DIRECTIVES],
2828
providers: const [HeroService, ROUTER_PROVIDERS])
2929
@RouteConfig(const [

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import 'heroes_component.dart';
2121
providers: const [ROUTER_PROVIDERS, HeroService]
2222
// #enddocregion directives-and-providers
2323
)
24-
// #docregion route-config
24+
// #docregion config
2525
@RouteConfig(const [
2626
const Route(path: '/heroes', name: 'Heroes', component: HeroesComponent)
2727
])
28-
// #enddocregion route-config
28+
// #enddocregion config
2929
class AppComponent {
3030
String title = 'Tour of Heroes';
3131
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import 'hero_service.dart';
1212

1313
@Component(
1414
selector: 'my-dashboard',
15-
// #docregion template-url
15+
// #docregion templateUrl
1616
templateUrl: 'dashboard_component.html',
17-
// #enddocregion template-url
17+
// #enddocregion templateUrl
1818
// #docregion css
1919
styleUrls: const ['dashboard_component.css']
2020
// #enddocregion css
@@ -35,13 +35,13 @@ class DashboardComponent implements OnInit {
3535
heroes = (await _heroService.getHeroes()).skip(1).take(4).toList();
3636
}
3737

38-
// #docregion goto-detail
38+
// #docregion gotoDetail
3939
void gotoDetail(Hero hero) {
4040
var link = [
4141
'HeroDetail',
4242
{'id': hero.id.toString()}
4343
];
4444
_router.navigate(link);
4545
}
46-
// #enddocregion goto-detail
46+
// #enddocregion gotoDetail
4747
}

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

+8-10
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,23 @@ import 'dart:html';
66
// #docregion import-oninit
77
import 'package:angular2/core.dart';
88
// #enddocregion import-oninit
9-
// #docregion import-route-params
9+
// #docregion router
1010
import 'package:angular2/router.dart';
11-
// #enddocregion import-route-params
11+
// #enddocregion router
1212

1313
import 'hero.dart';
1414
// #docregion import-hero-service
1515
import 'hero_service.dart';
1616
// #enddocregion import-hero-service
1717

18-
// #docregion extract-template
1918
@Component(
2019
selector: 'my-hero-detail',
21-
// #docregion template-url
20+
// #docregion templateUrl
2221
templateUrl: 'hero_detail_component.html',
23-
// #enddocregion template-url, v2
22+
// #enddocregion templateUrl, v2
2423
styleUrls: const ['hero_detail_component.css']
2524
// #docregion v2
2625
)
27-
// #enddocregion extract-template
2826
// #docregion implement
2927
class HeroDetailComponent implements OnInit {
3028
// #enddocregion implement
@@ -36,19 +34,19 @@ class HeroDetailComponent implements OnInit {
3634
HeroDetailComponent(this._heroService, this._routeParams);
3735
// #enddocregion ctor
3836

39-
// #docregion ng-oninit
37+
// #docregion ngOnInit
4038
Future<Null> ngOnInit() async {
4139
// #docregion get-id
4240
var idString = _routeParams.get('id');
4341
var id = int.parse(idString, onError: (_) => null);
4442
// #enddocregion get-id
4543
if (id != null) hero = await (_heroService.getHero(id));
4644
}
47-
// #enddocregion ng-oninit
45+
// #enddocregion ngOnInit
4846

49-
// #docregion go-back
47+
// #docregion goBack
5048
void goBack() {
5149
window.history.back();
5250
}
53-
// #enddocregion go-back
51+
// #enddocregion goBack
5452
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class HeroService {
1616
const Duration(seconds: 2), () => mockHeroes);
1717
}
1818

19-
// #docregion get-hero
19+
// #docregion getHero
2020
Future<Hero> getHero(int id) async =>
2121
(await getHeroes()).firstWhere((hero) => hero.id == id);
22-
// #enddocregion get-hero
22+
// #enddocregion getHero
2323
}

public/docs/_examples/toh-5/dart/web/styles_1.css

-24
This file was deleted.

public/docs/_examples/toh-5/ts/app/app.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import { Component } from '@angular/core';
1414
<router-outlet></router-outlet>
1515
`,
1616
// #enddocregion template
17-
// #docregion style-urls
17+
// #docregion styleUrls
1818
styleUrls: ['app/app.component.css'],
19-
// #enddocregion style-urls
19+
// #enddocregion styleUrls
2020
})
2121
export class AppComponent {
2222
title = 'Tour of Heroes';
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// #docregion
2-
// #docregion routing-config
2+
// #docregion config
33
import { Routes, RouterModule } from '@angular/router';
44

55
import { HeroesComponent } from './heroes.component';
@@ -10,8 +10,8 @@ const appRoutes: Routes = [
1010
component: HeroesComponent
1111
}
1212
];
13-
// #enddocregion routing-config
13+
// #enddocregion config
1414

15-
// #docregion routing-export
15+
// #docregion export
1616
export const routing = RouterModule.forRoot(appRoutes);
17-
// #enddocregion routing-export
17+
// #enddocregion export

public/docs/_examples/toh-5/ts/app/dashboard.component.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { HeroService } from './hero.service';
1010

1111
@Component({
1212
selector: 'my-dashboard',
13-
// #docregion template-url
13+
// #docregion templateUrl
1414
templateUrl: 'app/dashboard.component.html',
15-
// #enddocregion template-url
15+
// #enddocregion templateUrl
1616
// #docregion css
1717
styleUrls: ['app/dashboard.component.css']
1818
// #enddocregion css
@@ -34,10 +34,10 @@ export class DashboardComponent implements OnInit {
3434
.then(heroes => this.heroes = heroes.slice(1, 5));
3535
}
3636

37-
// #docregion goto-detail
37+
// #docregion gotoDetail
3838
gotoDetail(hero: Hero) {
3939
let link = ['/detail', hero.id];
4040
this.router.navigate(link);
4141
}
42-
// #enddocregion goto-detail
42+
// #enddocregion gotoDetail
4343
}

public/docs/_examples/toh-5/ts/app/hero-detail.component.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,23 @@
33
// #docregion import-oninit, v2
44
import { Component, OnInit } from '@angular/core';
55
// #enddocregion import-oninit
6-
// #docregion import-activated-route
6+
// #docregion router
77
import { ActivatedRoute, Params } from '@angular/router';
8-
// #enddocregion import-activated-route
8+
// #enddocregion router
99

1010
import { Hero } from './hero';
1111
// #docregion import-hero-service
1212
import { HeroService } from './hero.service';
1313
// #enddocregion import-hero-service
1414

15-
// #docregion extract-template
1615
@Component({
1716
selector: 'my-hero-detail',
18-
// #docregion template-url
17+
// #docregion templateUrl
1918
templateUrl: 'app/hero-detail.component.html',
20-
// #enddocregion template-url, v2
19+
// #enddocregion templateUrl, v2
2120
styleUrls: ['app/hero-detail.component.css']
2221
// #docregion v2
2322
})
24-
// #enddocregion extract-template
2523
// #docregion implement
2624
export class HeroDetailComponent implements OnInit {
2725
// #enddocregion implement
@@ -34,7 +32,7 @@ export class HeroDetailComponent implements OnInit {
3432
}
3533
// #enddocregion ctor
3634

37-
// #docregion ng-oninit
35+
// #docregion ngOnInit
3836
ngOnInit() {
3937
// #docregion get-id
4038
this.route.params.forEach((params: Params) => {
@@ -44,11 +42,11 @@ export class HeroDetailComponent implements OnInit {
4442
});
4543
// #enddocregion get-id
4644
}
47-
// #enddocregion ng-oninit
45+
// #enddocregion ngOnInit
4846

49-
// #docregion go-back
47+
// #docregion goBack
5048
goBack() {
5149
window.history.back();
5250
}
53-
// #enddocregion go-back
51+
// #enddocregion goBack
5452
}

public/docs/_examples/toh-5/ts/app/hero.service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export class HeroService {
1717
);
1818
}
1919

20-
// #docregion get-hero
20+
// #docregion getHero
2121
getHero(id: number) {
2222
return this.getHeroes()
2323
.then(heroes => heroes.find(hero => hero.id === id));
2424
}
25-
// #enddocregion get-hero
25+
// #enddocregion getHero
2626
}

public/docs/_examples/toh-5/ts/styles.1.css

-24
This file was deleted.

0 commit comments

Comments
 (0)