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

Commit dfd46af

Browse files
chalinkwalrath
authored andcommitted
docs(toh-6): post-RC5 Dart resync and TS fixes (#2095)
* toh-6: trim spaces from cache file to simplify diff * toh-6: copy latest over cache before editing latest * docs(toh-6): post-RC5 Dart resync and TS fixes Contributes to #2077. TS-side changes include: - Merged three versions of `app/app.module{,1,2}.ts` into a single file and used docregions instead. - Misnamed files: - `rxjs-operators.ts` -> `rxjs-extensions.ts` - `hero-search.service.html` -> `hero-search.component.html` - Fixed BAD FILENAME error. Lint reports no errors and toh-6 e2e tests pass.
1 parent ea45782 commit dfd46af

File tree

8 files changed

+110
-182
lines changed

8 files changed

+110
-182
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
// #docregion , search
1+
// #docregion
22
import 'dart:async';
33

44
import 'package:angular2/core.dart';
55
import 'package:angular2/router.dart';
66

77
import 'hero.dart';
88
import 'hero_service.dart';
9+
// #docregion search
910
import 'hero_search_component.dart';
1011

1112
@Component(

public/docs/_examples/toh-6/dart/web/main.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// #docplaster
2-
// #docregion final
3-
// #docregion v1
2+
// #docregion , v1, v2
43
import 'package:angular2/core.dart';
54
import 'package:angular2/platform/browser.dart';
65
import 'package:angular2_tour_of_heroes/app_component.dart';
@@ -15,7 +14,7 @@ void main() {
1514
// [provide(Client, useFactory: () => new BrowserClient(), deps: [])]
1615
);
1716
}
18-
// #enddocregion final
17+
// #enddocregion v2,
1918
/*
2019
// #docregion v1
2120
import 'package:http/browser_client.dart';

public/docs/_examples/toh-6/ts/app/app.module.1.ts

-44
This file was deleted.

public/docs/_examples/toh-6/ts/app/app.module.2.ts

-44
This file was deleted.

public/docs/_examples/toh-6/ts/app/app.module.ts

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,57 @@
1-
// #docregion
1+
// #docplaster
2+
// #docregion , v1, v2
23
import { NgModule } from '@angular/core';
34
import { BrowserModule } from '@angular/platform-browser';
45
import { FormsModule } from '@angular/forms';
6+
import { HttpModule } from '@angular/http';
57

8+
// #enddocregion v1
69
// Imports for loading & configuring the in-memory web api
7-
import { HttpModule, XHRBackend } from '@angular/http';
10+
import { XHRBackend } from '@angular/http';
811

912
import { InMemoryBackendService, SEED_DATA } from 'angular2-in-memory-web-api';
1013
import { InMemoryDataService } from './in-memory-data.service';
1114

15+
// #docregion v1
1216
import { AppComponent } from './app.component';
1317
import { routing } from './app.routing';
1418

1519
import { HeroesComponent } from './heroes.component';
1620
import { DashboardComponent } from './dashboard.component';
1721
import { HeroDetailComponent } from './hero-detail.component';
22+
import { HeroService } from './hero.service';
23+
// #enddocregion v1, v2
24+
// #docregion search
1825
import { HeroSearchComponent } from './hero-search.component';
26+
// #docregion v1, v2
1927

20-
import { HeroService } from './hero.service';
21-
28+
// #enddocregion search
2229
@NgModule({
2330
imports: [
2431
BrowserModule,
2532
FormsModule,
2633
routing,
2734
HttpModule
2835
],
36+
// #docregion search
2937
declarations: [
3038
AppComponent,
3139
HeroesComponent,
3240
DashboardComponent,
3341
HeroDetailComponent,
42+
// #enddocregion v1, v2
3443
HeroSearchComponent
44+
// #docregion v1, v2
3545
],
46+
// #enddocregion search
3647
providers: [
3748
HeroService,
49+
// #enddocregion v1
3850
{ provide: XHRBackend, useClass: InMemoryBackendService }, // in-mem server
3951
{ provide: SEED_DATA, useClass: InMemoryDataService } // in-mem server data
52+
// #docregion v1
4053
],
4154
bootstrap: [ AppComponent ]
4255
})
4356
export class AppModule {
4457
}
45-
// #enddocregion

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

+20-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ block includes
66
- var _Angular_Http = 'Dart <code>BrowserClient</code>'
77
- var _httpUrl = 'https://pub.dartlang.org/packages/http'
88
- var _Angular_http_library = 'Dart <a href="' + _httpUrl + '"><b>http</b></a> package'
9-
- var _HTTP_PROVIDERS = 'BrowserClient'
9+
- var _HttpModule = 'BrowserClient'
1010
- var _JSON_stringify = 'JSON.encode'
1111

1212
block start-server-and-watch
@@ -17,15 +17,15 @@ block start-server-and-watch
1717

1818
code-example(language="bash").
1919
pub serve
20-
20+
2121
block http-library
2222
:marked
23-
We'll be using the !{_Angular_http_library}'s
23+
We'll be using the !{_Angular_http_library}'s
2424
`BrowserClient` class to communicate with a server.
2525

2626
### Pubspec updates
27-
28-
We need to add package dependencies for the
27+
28+
We need to add package dependencies for the
2929
`stream_transformers` and !{_Angular_http_library}s.
3030

3131
We also need to add a `resolved_identifiers` entry, to inform the [angular2
@@ -45,10 +45,21 @@ block http-providers
4545
:marked
4646
Before our app can use `#{_Http}`, we have to register it as a service provider.
4747

48+
We should be able to access `!{_Http}` services from anywhere in the application.
49+
So we register it in the `bootstrap` call where we
50+
launch the application and its root `AppComponent`.
51+
52+
+makeExcerpt('app/main.ts','v1')
53+
54+
:marked
55+
Notice that we supply `!{_HttpModule}` in a list, as the second parameter to
56+
the `bootstrap` method. This has the same effect as the `providers` list in
57+
`@Component` annotation.
58+
4859
block backend
4960
:marked
5061
We want to replace `BrowserClient`, the service that talks to the remote server,
51-
with the in-memory web API service.
62+
with the in-memory web API service.
5263
Our in-memory web API service, shown below, is implemented using the
5364
`http` library `MockClient` class.
5465
All `http` client implementations share a common `Client` interface, so
@@ -77,7 +88,7 @@ block hero-detail-comp-updates
7788
:marked
7889
### Edit in the *HeroDetailComponent*
7990

80-
We already have `HeroDetailComponent` for viewing details about a specific hero.
91+
We already have `HeroDetailComponent` for viewing details about a specific hero.
8192
Supporting edit functionality is a natural extension of the detail view,
8293
so we are able to reuse `HeroDetailComponent` with a few tweaks.
8394

@@ -87,9 +98,6 @@ block hero-detail-comp-save-and-goback
8798
block add-new-hero-via-detail-comp
8899
//- N/A
89100
90-
block heroes-comp-directives
91-
//- N/A
92-
93101
block heroes-comp-add
94102
//- N/A
95103
@@ -194,10 +202,10 @@ block file-summary
194202
lib/hero_search_component.dart,
195203
lib/hero_search_component.html,
196204
lib/hero_search_service.dart`)
197-
205+
198206
+makeTabs(
199207
`toh-6/dart/pubspec.yaml,
200208
toh-6/dart/web/main.dart`,
201-
`,final`,
209+
null,
202210
`pubspec.yaml,
203211
web/main.dart`)

0 commit comments

Comments
 (0)