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

docs(toh-6): post-RC5 Dart resync and TS fixes #2095

Merged
merged 3 commits into from
Aug 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// #docregion , search
// #docregion
import 'dart:async';

import 'package:angular2/core.dart';
import 'package:angular2/router.dart';

import 'hero.dart';
import 'hero_service.dart';
// #docregion search
import 'hero_search_component.dart';

@Component(
Expand Down
5 changes: 2 additions & 3 deletions public/docs/_examples/toh-6/dart/web/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// #docplaster
// #docregion final
// #docregion v1
// #docregion , v1, v2
import 'package:angular2/core.dart';
import 'package:angular2/platform/browser.dart';
import 'package:angular2_tour_of_heroes/app_component.dart';
Expand All @@ -15,7 +14,7 @@ void main() {
// [provide(Client, useFactory: () => new BrowserClient(), deps: [])]
);
}
// #enddocregion final
// #enddocregion v2,
/*
// #docregion v1
import 'package:http/browser_client.dart';
Expand Down
44 changes: 0 additions & 44 deletions public/docs/_examples/toh-6/ts/app/app.module.1.ts

This file was deleted.

44 changes: 0 additions & 44 deletions public/docs/_examples/toh-6/ts/app/app.module.2.ts

This file was deleted.

22 changes: 17 additions & 5 deletions public/docs/_examples/toh-6/ts/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,57 @@
// #docregion
// #docplaster
// #docregion , v1, v2
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

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

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

// #docregion v1
import { AppComponent } from './app.component';
import { routing } from './app.routing';

import { HeroesComponent } from './heroes.component';
import { DashboardComponent } from './dashboard.component';
import { HeroDetailComponent } from './hero-detail.component';
import { HeroService } from './hero.service';
// #enddocregion v1, v2
// #docregion search
import { HeroSearchComponent } from './hero-search.component';
// #docregion v1, v2

import { HeroService } from './hero.service';

// #enddocregion search
@NgModule({
imports: [
BrowserModule,
FormsModule,
routing,
HttpModule
],
// #docregion search
declarations: [
AppComponent,
HeroesComponent,
DashboardComponent,
HeroDetailComponent,
// #enddocregion v1, v2
HeroSearchComponent
// #docregion v1, v2
],
// #enddocregion search
providers: [
HeroService,
// #enddocregion v1
{ provide: XHRBackend, useClass: InMemoryBackendService }, // in-mem server
{ provide: SEED_DATA, useClass: InMemoryDataService } // in-mem server data
// #docregion v1
],
bootstrap: [ AppComponent ]
})
export class AppModule {
}
// #enddocregion
32 changes: 20 additions & 12 deletions public/docs/dart/latest/tutorial/toh-pt6.jade
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ block includes
- var _Angular_Http = 'Dart <code>BrowserClient</code>'
- var _httpUrl = 'https://pub.dartlang.org/packages/http'
- var _Angular_http_library = 'Dart <a href="' + _httpUrl + '"><b>http</b></a> package'
- var _HTTP_PROVIDERS = 'BrowserClient'
- var _HttpModule = 'BrowserClient'
- var _JSON_stringify = 'JSON.encode'

block start-server-and-watch
Expand All @@ -17,15 +17,15 @@ block start-server-and-watch

code-example(language="bash").
pub serve

block http-library
:marked
We'll be using the !{_Angular_http_library}'s
We'll be using the !{_Angular_http_library}'s
`BrowserClient` class to communicate with a server.

### Pubspec updates
We need to add package dependencies for the

We need to add package dependencies for the
`stream_transformers` and !{_Angular_http_library}s.

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

We should be able to access `!{_Http}` services from anywhere in the application.
So we register it in the `bootstrap` call where we
launch the application and its root `AppComponent`.

+makeExcerpt('app/main.ts','v1')

:marked
Notice that we supply `!{_HttpModule}` in a list, as the second parameter to
the `bootstrap` method. This has the same effect as the `providers` list in
`@Component` annotation.

block backend
:marked
We want to replace `BrowserClient`, the service that talks to the remote server,
with the in-memory web API service.
with the in-memory web API service.
Our in-memory web API service, shown below, is implemented using the
`http` library `MockClient` class.
All `http` client implementations share a common `Client` interface, so
Expand Down Expand Up @@ -77,7 +88,7 @@ block hero-detail-comp-updates
:marked
### Edit in the *HeroDetailComponent*

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

Expand All @@ -87,9 +98,6 @@ block hero-detail-comp-save-and-goback
block add-new-hero-via-detail-comp
//- N/A

block heroes-comp-directives
//- N/A

block heroes-comp-add
//- N/A

Expand Down Expand Up @@ -194,10 +202,10 @@ block file-summary
lib/hero_search_component.dart,
lib/hero_search_component.html,
lib/hero_search_service.dart`)

+makeTabs(
`toh-6/dart/pubspec.yaml,
toh-6/dart/web/main.dart`,
`,final`,
null,
`pubspec.yaml,
web/main.dart`)
Loading