diff --git a/.travis.yml b/.travis.yml index 755b29e6a7..bf6b8894aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ env: - DBUS_SESSION_BUS_ADDRESS=/dev/null - DISPLAY=:99.0 - CHROME_BIN=chromium-browser - - LATEST_RELEASE=2.0.0-rc.4 + - LATEST_RELEASE=2.0.0-rc.5 - TASK_FLAGS="--dgeni-log=warn" # - TASK_FLAGS="" matrix: diff --git a/gulpfile.js b/gulpfile.js index c6e15ae13f..33a555d09e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -344,10 +344,14 @@ function runE2eDartTests(appDir, outputFile) { gutil.log('http-server failed to launch over ' + deployDir); return false; } - var pubUpgradeSpawnInfo = spawnExt('pub', ['upgrade'], { cwd: appDir }); - var prepPromise = pubUpgradeSpawnInfo.promise.then(function (data) { - return spawnExt('pub', ['build'], { cwd: appDir }).promise; - }); + if (argv.pub === false) { + var prepPromise = Promise.resolve(true); + } else { + var pubUpgradeSpawnInfo = spawnExt('pub', ['upgrade'], { cwd: appDir }); + var prepPromise = pubUpgradeSpawnInfo.promise.then(function (data) { + return spawnExt('pub', ['build'], { cwd: appDir }).promise; + }); + } return runProtractor(prepPromise, appDir, appRunSpawnInfo, outputFile); } @@ -441,7 +445,7 @@ gulp.task('add-example-boilerplate', function(done) { // copies boilerplate files to locations // where an example app is found gulp.task('_copy-example-boilerplate', function (done) { - if (!argv.fast) buildStyles(copyExampleBoilerplate, done); + return argv.fast ? done() : buildStyles(copyExampleBoilerplate, done); }); //Builds Angular 2 Docs CSS file from Bootstrap npm LESS source @@ -604,20 +608,20 @@ gulp.task('build-dart-cheatsheet', [], function() { gulp.task('dartdoc', ['pub upgrade'], function() { const ngRepoPath = ngPathFor('dart'); - if (argv.fast && fs.existsSync(path.resolve(ngRepoPath, 'doc'))) { - gutil.log('Skipping dartdoc: --fast flag enabled and "doc" dir exists'); + if (argv.fast && fs.existsSync(path.resolve(ngRepoPath, 'docs', 'api'))) { + gutil.log('Skipping dartdoc: --fast flag enabled and "docs/api" dir exists'); return true; } checkAngularProjectPath(ngRepoPath); const topLevelLibFilePath = path.resolve(ngRepoPath, 'lib', 'angular2.dart'); const tmpPath = topLevelLibFilePath + '.disabled'; - if (!fs.existsSync(topLevelLibFilePath)) throw new Error(`Missing file: ${topLevelLibFilePath}`); - fs.renameSync(topLevelLibFilePath, tmpPath); + renameIfExistsSync(topLevelLibFilePath, tmpPath); gutil.log(`Hiding top-level angular2 library: ${topLevelLibFilePath}`); - const dartdoc = spawnExt('dartdoc', ['--output', 'doc/api', '--add-crossdart'], { cwd: ngRepoPath}); + // Remove dartdoc '--add-crossdart' flag while we are fixing links to API pages. + const dartdoc = spawnExt('dartdoc', ['--output', 'docs/api'], { cwd: ngRepoPath}); return dartdoc.promise.finally(() => { gutil.log(`Restoring top-level angular2 library: ${topLevelLibFilePath}`); - fs.renameSync(tmpPath, topLevelLibFilePath); + renameIfExistsSync(tmpPath, topLevelLibFilePath); }) }); @@ -1235,15 +1239,14 @@ function buildDartCheatsheet() { function buildApiDocsForDart() { - const apiDir = 'api'; const vers = 'latest'; const dab = require('./tools/dart-api-builder/dab')(ANGULAR_IO_PROJECT_PATH); const log = dab.log; log.level = _dgeniLogLevel; const dabInfo = dab.dartPkgConfigInfo; - dabInfo.ngIoDartApiDocPath = path.join(DOCS_PATH, 'dart', vers, apiDir); - dabInfo.ngDartDocPath = path.join(ngPathFor('dart'), 'doc', apiDir); + dabInfo.ngIoDartApiDocPath = path.join(DOCS_PATH, 'dart', vers, 'api'); + dabInfo.ngDartDocPath = path.join(ngPathFor('dart'), 'docs', 'api'); // Exclude API entries for developer/internal libraries. Also exclude entries for // the top-level catch all "angular2" library (otherwise every entry appears twice). dabInfo.excludeLibRegExp = new RegExp(/^(?!angular2)|\.testing|_|codegen|^angular2$/); @@ -1455,3 +1458,11 @@ function checkAngularProjectPath(_ngPath) { if (fs.existsSync(ngPath)) return; throw new Error('API related tasks require the angular2 repo to be at ' + ngPath); } + +function renameIfExistsSync(oldPath, newPath) { + if (fs.existsSync(oldPath)) { + fs.renameSync(oldPath, newPath); + } else { + gutil.log(`renameIfExistsSync cannot find file to rename: ${oldPath}`); + } +} diff --git a/public/_includes/_util-fns.jade b/public/_includes/_util-fns.jade index d9317707f3..946f82d2f4 100644 --- a/public/_includes/_util-fns.jade +++ b/public/_includes/_util-fns.jade @@ -39,6 +39,15 @@ //- Location of sample code - var _liveLink = 'live link'; +//- NgModule related +- var _AppModuleVsAppComp = 'AppModule' +- var _appModuleTsVsAppCompTs = 'app/app.module.ts' +- var _appModuleTsVsMainTs = 'app/app.module.ts' +- var _bootstrapModule = 'bootstrapModule' +- var _moduleVsComp = 'module' +- var _moduleVsRootComp = 'module' +- var _platformBrowserDynamicVsBootStrap = 'platformBrowserDynamic' + //- Other - var _truthy = 'truthy'; - var _falsey = 'falsey'; @@ -90,14 +99,14 @@ mixin makeExample(_filePath, region, _title, stylePatterns) //- ending is given or is just (), then the title will be suffixed with //- either "(excerpt)", or "(#{_region})" when _region is defined. mixin makeExcerpt(_filePath, _region, _title, stylePatterns) - - var matches = _filePath.match(/(.*)\s+\(([\w ]*)\)$/); + - var matches = _filePath.match(/(.*)\s+\(([^\)]*)\)$/); - var parenText; - if (matches) { _filePath = matches[1]; parenText = matches[2]; } - var adjustments = adjustExamplePathAndTitle({filePath:_filePath, title:_title}); - var filePath = adjustments.filePath; - var title = adjustments.title; - - var region = _region || parenText; - - var excerpt = !region || parenText === '' ? 'excerpt' : parenText || region; + - var region = _region || (_region === '' ? '' : parenText); + - var excerpt = parenText || region || 'excerpt'; - if (title) title = title + ' (' + excerpt + ')'; +makeExample(filePath, region, title, stylePatterns)(format='.') @@ -214,8 +223,8 @@ script. - // E.g. of a project relative path is 'app/main.ts' - if (ex.title === null || ex.title === undefined) { - // Title is not given so take it to be ex.filePath. -- // Is title like styles.1.css? Then drop the '.1' qualifier: -- var matches = ex.filePath.match(/^(.*)\.\d(\.\w+)$/); +- // Title like styles.1.css or foo_1.dart? Then drop the '.1' or '_1' qualifier: +- var matches = ex.filePath.match(/^(.*)[\._]\d(\.\w+)$/); - ex.title = matches ? matches[1] + matches[2] : ex.filePath; - } - ex.filePath = getExampleName() + '/' + _docsFor + '/' + ex.filePath; diff --git a/public/docs/_examples/architecture/dart/pubspec.yaml b/public/docs/_examples/architecture/dart/pubspec.yaml index 4da6837c0b..84d0121f5f 100644 --- a/public/docs/_examples/architecture/dart/pubspec.yaml +++ b/public/docs/_examples/architecture/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/attribute-directives/dart/pubspec.yaml b/public/docs/_examples/attribute-directives/dart/pubspec.yaml index 2afe4114d8..6cfb11ee2d 100644 --- a/public/docs/_examples/attribute-directives/dart/pubspec.yaml +++ b/public/docs/_examples/attribute-directives/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/cb-a1-a2-quick-reference/ts/app/app.module.ts b/public/docs/_examples/cb-a1-a2-quick-reference/ts/app/app.module.ts index 08391524b9..dec4a4e223 100644 --- a/public/docs/_examples/cb-a1-a2-quick-reference/ts/app/app.module.ts +++ b/public/docs/_examples/cb-a1-a2-quick-reference/ts/app/app.module.ts @@ -2,17 +2,16 @@ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; -import { RouterModule } from '@angular/router'; import { AppComponent } from './app.component'; import { MovieListComponent } from './movie-list.component'; -import { routes } from './app.routes'; +import { routing } from './app.routing'; @NgModule({ imports: [ BrowserModule, FormsModule, - RouterModule.forRoot(routes, {}) + routing ], declarations: [ AppComponent, diff --git a/public/docs/_examples/cb-a1-a2-quick-reference/ts/app/app.routes.ts b/public/docs/_examples/cb-a1-a2-quick-reference/ts/app/app.routes.ts deleted file mode 100644 index 67aa75ed25..0000000000 --- a/public/docs/_examples/cb-a1-a2-quick-reference/ts/app/app.routes.ts +++ /dev/null @@ -1,9 +0,0 @@ -// #docregion -import { RouterConfig } from '@angular/router'; - -import { MovieListComponent } from './movie-list.component'; - -export const routes: RouterConfig = [ - { path: '', redirectTo: '/movies', pathMatch: 'full' }, - { path: 'movies', component: MovieListComponent } -]; diff --git a/public/docs/_examples/cb-a1-a2-quick-reference/ts/app/app.routing.ts b/public/docs/_examples/cb-a1-a2-quick-reference/ts/app/app.routing.ts new file mode 100644 index 0000000000..fb042725eb --- /dev/null +++ b/public/docs/_examples/cb-a1-a2-quick-reference/ts/app/app.routing.ts @@ -0,0 +1,12 @@ +// #docregion +import { ModuleWithProviders } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; + +import { MovieListComponent } from './movie-list.component'; + +const routes: Routes = [ + { path: '', redirectTo: '/movies', pathMatch: 'full' }, + { path: 'movies', component: MovieListComponent } +]; + +export const routing: ModuleWithProviders = RouterModule.forRoot(routes); diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/app.module.ts b/public/docs/_examples/cb-dependency-injection/ts/app/app.module.ts index 326ea4e945..7b9487e815 100644 --- a/public/docs/_examples/cb-dependency-injection/ts/app/app.module.ts +++ b/public/docs/_examples/cb-dependency-injection/ts/app/app.module.ts @@ -1,15 +1,16 @@ // #docregion import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; -import { XHRBackend } from '@angular/http'; -// import { appRouterProviders } from './app.routes'; +import { HttpModule } from '@angular/http'; + +/* import { routing } from './app.routing';*/ import { LocationStrategy, HashLocationStrategy } from '@angular/common'; import { NgModule } from '@angular/core'; import { HeroData } from './hero-data'; -import { InMemoryBackendService, - SEED_DATA } from 'angular2-in-memory-web-api'; +import { InMemoryWebApiModule } from 'angular2-in-memory-web-api'; + import { AppComponent } from './app.component'; import { HeroBioComponent } from './hero-bio.component'; @@ -31,44 +32,43 @@ import { ParentFinderComponent, BethComponent, BobComponent } from './parent-finder.component'; -const DIRECTIVES = [ +const declarations = [ + AppComponent, HeroBiosComponent, HeroBiosAndContactsComponent, HeroBioComponent, HeroesBaseComponent, SortedHeroesComponent, HeroOfTheMonthComponent, HeroContactComponent, HighlightDirective, ParentFinderComponent, - AppComponent ]; -const B_DIRECTIVES = [ BarryComponent, BethComponent, BobComponent ]; +const a_components = [AliceComponent, AlexComponent ]; -// #docregion C_DIRECTIVES -const C_DIRECTIVES = [ +const b_components = [ BarryComponent, BethComponent, BobComponent ]; + +const c_components = [ CarolComponent, ChrisComponent, CraigComponent, CathyComponent ]; -// #enddocregion C_DIRECTIVES -// #docregion bootstrap @NgModule({ - imports: [ BrowserModule, FormsModule ], - declarations: [ ...DIRECTIVES, - ...B_DIRECTIVES, - ...C_DIRECTIVES, - AliceComponent, - AlexComponent ], + imports: [ + BrowserModule, + FormsModule, + HttpModule, + InMemoryWebApiModule.forRoot(HeroData) + // routing TODO: add routes + ], + declarations: [ + declarations, + a_components, + b_components, + c_components, + ], bootstrap: [ AppComponent ], + // #docregion providers providers: [ - // appRouterProviders, TODO: add routes - { provide: LocationStrategy, useClass: HashLocationStrategy }, - - { provide: XHRBackend, useClass: InMemoryBackendService }, // in-mem server - { provide: SEED_DATA, useClass: HeroData } // in-mem server data + { provide: LocationStrategy, useClass: HashLocationStrategy } ] + // #enddocregion providers }) -export class AppModule { - constructor() { - } -} -// #enddocregion bootstraps - +export class AppModule { } diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/app.routes.ts b/public/docs/_examples/cb-dependency-injection/ts/app/app.routes.ts deleted file mode 100644 index c8eb6ee683..0000000000 --- a/public/docs/_examples/cb-dependency-injection/ts/app/app.routes.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { provideRouter, RouterConfig } from '@angular/router'; - -const routes: RouterConfig = []; - -export const appRouterProviders = [ - provideRouter(routes) -]; diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/app.routing.ts b/public/docs/_examples/cb-dependency-injection/ts/app/app.routing.ts new file mode 100644 index 0000000000..2d3556371d --- /dev/null +++ b/public/docs/_examples/cb-dependency-injection/ts/app/app.routing.ts @@ -0,0 +1,10 @@ +import { ModuleWithProviders } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; + +const routes: Routes = []; + +export const routing: ModuleWithProviders = RouterModule.forRoot(routes); + +export const appRoutingProviders: any[] = [ + +]; diff --git a/public/docs/_examples/component-styles/dart/pubspec.yaml b/public/docs/_examples/component-styles/dart/pubspec.yaml index 731e9e5d8e..0bdc04cb83 100755 --- a/public/docs/_examples/component-styles/dart/pubspec.yaml +++ b/public/docs/_examples/component-styles/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/dependency-injection/dart/pubspec.yaml b/public/docs/_examples/dependency-injection/dart/pubspec.yaml index b3b5a1cb42..0ef93066be 100644 --- a/public/docs/_examples/dependency-injection/dart/pubspec.yaml +++ b/public/docs/_examples/dependency-injection/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/displaying-data/dart/pubspec.yaml b/public/docs/_examples/displaying-data/dart/pubspec.yaml index 8c57ff7300..c5ef73f402 100644 --- a/public/docs/_examples/displaying-data/dart/pubspec.yaml +++ b/public/docs/_examples/displaying-data/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/forms/dart/pubspec.yaml b/public/docs/_examples/forms/dart/pubspec.yaml index 89b203abf0..51664a3cd5 100644 --- a/public/docs/_examples/forms/dart/pubspec.yaml +++ b/public/docs/_examples/forms/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/hierarchical-dependency-injection/dart/pubspec.yaml b/public/docs/_examples/hierarchical-dependency-injection/dart/pubspec.yaml index d81a211702..9575041134 100644 --- a/public/docs/_examples/hierarchical-dependency-injection/dart/pubspec.yaml +++ b/public/docs/_examples/hierarchical-dependency-injection/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/lifecycle-hooks/dart/lib/after_view_component.dart b/public/docs/_examples/lifecycle-hooks/dart/lib/after_view_component.dart index c405c874ac..9c2413c559 100644 --- a/public/docs/_examples/lifecycle-hooks/dart/lib/after_view_component.dart +++ b/public/docs/_examples/lifecycle-hooks/dart/lib/after_view_component.dart @@ -7,7 +7,7 @@ import 'logger_service.dart'; ////////////////// // #docregion child-view @Component( - selector: 'my-child', + selector: 'my-child-view', template: '') class ChildViewComponent { String hero = 'Magneta'; @@ -20,7 +20,7 @@ class ChildViewComponent { // #docregion template template: '''
-- child view begins --
- +
-- child view ends --

{{comment}}

''', // #enddocregion template diff --git a/public/docs/_examples/lifecycle-hooks/dart/lib/do_check_component.dart b/public/docs/_examples/lifecycle-hooks/dart/lib/do_check_component.dart index 5483b9be8f..449b6e0092 100644 --- a/public/docs/_examples/lifecycle-hooks/dart/lib/do_check_component.dart +++ b/public/docs/_examples/lifecycle-hooks/dart/lib/do_check_component.dart @@ -92,7 +92,7 @@ class DoCheckComponent implements DoCheck, OnChanges { @Component( selector: 'do-check-parent', - templateUrl: 'on_changes_parent_component.html', + templateUrl: 'do_check_parent_component.html', styles: const ['.parent {background: Lavender}'], directives: const [DoCheckComponent]) class DoCheckParentComponent { diff --git a/public/docs/_examples/lifecycle-hooks/dart/lib/do_check_parent_component.html b/public/docs/_examples/lifecycle-hooks/dart/lib/do_check_parent_component.html new file mode 100644 index 0000000000..ef3c30be28 --- /dev/null +++ b/public/docs/_examples/lifecycle-hooks/dart/lib/do_check_parent_component.html @@ -0,0 +1,13 @@ +
+

{{title}}

+ + + + +
Power:
Hero.name:
+

+ + + + +
diff --git a/public/docs/_examples/lifecycle-hooks/dart/lib/on_changes_parent_component.html b/public/docs/_examples/lifecycle-hooks/dart/lib/on_changes_parent_component.html index 7889ce8e91..a0fd404931 100644 --- a/public/docs/_examples/lifecycle-hooks/dart/lib/on_changes_parent_component.html +++ b/public/docs/_examples/lifecycle-hooks/dart/lib/on_changes_parent_component.html @@ -7,8 +7,7 @@

- + - - + diff --git a/public/docs/_examples/lifecycle-hooks/dart/pubspec.yaml b/public/docs/_examples/lifecycle-hooks/dart/pubspec.yaml index 0710ddbb86..3624f56e05 100644 --- a/public/docs/_examples/lifecycle-hooks/dart/pubspec.yaml +++ b/public/docs/_examples/lifecycle-hooks/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/lifecycle-hooks/dart/web/main.dart b/public/docs/_examples/lifecycle-hooks/dart/web/main.dart index 5013275e6a..f9143d4116 100644 --- a/public/docs/_examples/lifecycle-hooks/dart/web/main.dart +++ b/public/docs/_examples/lifecycle-hooks/dart/web/main.dart @@ -1,8 +1,6 @@ -// #docregion import 'package:angular2/platform/browser.dart'; - import 'package:lifecycle_hooks/app_component.dart'; -main() { +void main() { bootstrap(AppComponent); } diff --git a/public/docs/_examples/lifecycle-hooks/ts/app/main.ts b/public/docs/_examples/lifecycle-hooks/ts/app/main.ts index 4acf5de663..2470c9595e 100644 --- a/public/docs/_examples/lifecycle-hooks/ts/app/main.ts +++ b/public/docs/_examples/lifecycle-hooks/ts/app/main.ts @@ -1,4 +1,3 @@ -// #docregion import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { AppModule } from './app.module'; diff --git a/public/docs/_examples/lifecycle-hooks/ts/app/on-changes-parent.component.html b/public/docs/_examples/lifecycle-hooks/ts/app/on-changes-parent.component.html index 5c76a6056c..a0fd404931 100644 --- a/public/docs/_examples/lifecycle-hooks/ts/app/on-changes-parent.component.html +++ b/public/docs/_examples/lifecycle-hooks/ts/app/on-changes-parent.component.html @@ -7,7 +7,7 @@

- + - + diff --git a/public/docs/_examples/ngmodule/ts/app/app.routing.3.ts b/public/docs/_examples/ngmodule/ts/app/app.routing.3.ts index 96eebf5dac..994807b5bd 100644 --- a/public/docs/_examples/ngmodule/ts/app/app.routing.3.ts +++ b/public/docs/_examples/ngmodule/ts/app/app.routing.3.ts @@ -1,3 +1,4 @@ +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; @@ -7,4 +8,4 @@ export const routes: Routes = [ { path: 'heroes', loadChildren: 'app/hero/hero.module.3' } ]; -export const routing = RouterModule.forRoot(routes); +export const routing: ModuleWithProviders = RouterModule.forRoot(routes); diff --git a/public/docs/_examples/ngmodule/ts/app/app.routing.ts b/public/docs/_examples/ngmodule/ts/app/app.routing.ts index 09fa0225d8..6e654ca649 100644 --- a/public/docs/_examples/ngmodule/ts/app/app.routing.ts +++ b/public/docs/_examples/ngmodule/ts/app/app.routing.ts @@ -1,4 +1,5 @@ // #docregion +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; @@ -11,5 +12,5 @@ export const routes: Routes = [ ]; // #docregion forRoot -export const routing = RouterModule.forRoot(routes); +export const routing: ModuleWithProviders = RouterModule.forRoot(routes); // #enddocregion forRoot diff --git a/public/docs/_examples/ngmodule/ts/app/contact/contact.routing.3.ts b/public/docs/_examples/ngmodule/ts/app/contact/contact.routing.3.ts index f90fc36789..5490649283 100644 --- a/public/docs/_examples/ngmodule/ts/app/contact/contact.routing.3.ts +++ b/public/docs/_examples/ngmodule/ts/app/contact/contact.routing.3.ts @@ -1,7 +1,8 @@ +import { ModuleWithProviders } from '@angular/core'; import { RouterModule } from '@angular/router'; import { ContactComponent } from './contact.component.3'; -export const routing = RouterModule.forChild([ +export const routing: ModuleWithProviders = RouterModule.forChild([ { path: 'contact', component: ContactComponent} ]); diff --git a/public/docs/_examples/ngmodule/ts/app/contact/contact.routing.ts b/public/docs/_examples/ngmodule/ts/app/contact/contact.routing.ts index fe9af67fbf..065e78dabd 100644 --- a/public/docs/_examples/ngmodule/ts/app/contact/contact.routing.ts +++ b/public/docs/_examples/ngmodule/ts/app/contact/contact.routing.ts @@ -1,9 +1,10 @@ +import { ModuleWithProviders } from '@angular/core'; import { RouterModule } from '@angular/router'; import { ContactComponent } from './contact.component'; // #docregion routing -export const routing = RouterModule.forChild([ +export const routing: ModuleWithProviders = RouterModule.forChild([ { path: 'contact', component: ContactComponent} ]); // #enddocregion diff --git a/public/docs/_examples/ngmodule/ts/app/crisis/crisis.routing.ts b/public/docs/_examples/ngmodule/ts/app/crisis/crisis.routing.ts index a0e8b850b7..c9aeb83d5f 100644 --- a/public/docs/_examples/ngmodule/ts/app/crisis/crisis.routing.ts +++ b/public/docs/_examples/ngmodule/ts/app/crisis/crisis.routing.ts @@ -1,3 +1,4 @@ +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; @@ -10,4 +11,4 @@ const routes: Routes = [ { path: ':id', component: CrisisDetailComponent } ]; -export const routing = RouterModule.forChild(routes); +export const routing: ModuleWithProviders = RouterModule.forChild(routes); diff --git a/public/docs/_examples/ngmodule/ts/app/hero/hero.routing.3.ts b/public/docs/_examples/ngmodule/ts/app/hero/hero.routing.3.ts index 181e48faf5..e14d4a7725 100644 --- a/public/docs/_examples/ngmodule/ts/app/hero/hero.routing.3.ts +++ b/public/docs/_examples/ngmodule/ts/app/hero/hero.routing.3.ts @@ -1,3 +1,4 @@ +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; @@ -15,4 +16,4 @@ const routes: Routes = [ } ]; -export const routing = RouterModule.forChild(routes); +export const routing: ModuleWithProviders = RouterModule.forChild(routes); diff --git a/public/docs/_examples/ngmodule/ts/app/hero/hero.routing.ts b/public/docs/_examples/ngmodule/ts/app/hero/hero.routing.ts index 951ffd7d12..7f364ee988 100644 --- a/public/docs/_examples/ngmodule/ts/app/hero/hero.routing.ts +++ b/public/docs/_examples/ngmodule/ts/app/hero/hero.routing.ts @@ -1,3 +1,4 @@ +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; @@ -15,4 +16,4 @@ const routes: Routes = [ } ]; -export const routing = RouterModule.forChild(routes); +export const routing: ModuleWithProviders = RouterModule.forChild(routes); diff --git a/public/docs/_examples/package.json b/public/docs/_examples/package.json index 7015bd0767..6c253c3e4c 100644 --- a/public/docs/_examples/package.json +++ b/public/docs/_examples/package.json @@ -35,7 +35,7 @@ "@angular/router": "3.0.0-rc.1", "@angular/router-deprecated": "2.0.0-rc.2", "@angular/upgrade": "2.0.0-rc.5", - "angular2-in-memory-web-api": "0.0.15", + "angular2-in-memory-web-api": "0.0.17", "bootstrap": "^3.3.6", "core-js": "^2.4.0", "reflect-metadata": "^0.1.3", diff --git a/public/docs/_examples/pipes/dart/pubspec.yaml b/public/docs/_examples/pipes/dart/pubspec.yaml index 4afa2870c0..8edddf0efa 100644 --- a/public/docs/_examples/pipes/dart/pubspec.yaml +++ b/public/docs/_examples/pipes/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/pipes/e2e-spec.ts b/public/docs/_examples/pipes/e2e-spec.ts index 01c9e5fd13..5f9c4607dc 100644 --- a/public/docs/_examples/pipes/e2e-spec.ts +++ b/public/docs/_examples/pipes/e2e-spec.ts @@ -64,7 +64,7 @@ describe('Pipes', function () { }); - it('should support flying heroes (pure) ', function () { + xit('should support flying heroes (pure) ', function () { let nameEle = element(by.css('flying-heroes input[type="text"]')); let canFlyCheckEle = element(by.css('flying-heroes #can-fly')); let mutateCheckEle = element(by.css('flying-heroes #mutate')); @@ -95,7 +95,7 @@ describe('Pipes', function () { }); - it('should support flying heroes (impure) ', function () { + xit('should support flying heroes (impure) ', function () { let nameEle = element(by.css('flying-heroes-impure input[type="text"]')); let canFlyCheckEle = element(by.css('flying-heroes-impure #can-fly')); let mutateCheckEle = element(by.css('flying-heroes-impure #mutate')); diff --git a/public/docs/_examples/quickstart/dart/pubspec.yaml b/public/docs/_examples/quickstart/dart/pubspec.yaml index 0c08200992..ec9d8d2f81 100644 --- a/public/docs/_examples/quickstart/dart/pubspec.yaml +++ b/public/docs/_examples/quickstart/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/quickstart/dart/web/styles_1.css b/public/docs/_examples/quickstart/dart/web/styles_1.css deleted file mode 100644 index 27e60d67c0..0000000000 --- a/public/docs/_examples/quickstart/dart/web/styles_1.css +++ /dev/null @@ -1,14 +0,0 @@ -/* #docregion */ -h1 { - color: #369; - font-family: Arial, Helvetica, sans-serif; - font-size: 250%; -} -body { - margin: 2em; -} - -/* -* See https://github.com/angular/angular.io/blob/master/public/docs/_examples/styles.css -* for the full set of master styles used by the documentation samples -*/ diff --git a/public/docs/_examples/quickstart/ts/styles.1.css b/public/docs/_examples/quickstart/ts/styles.1.css deleted file mode 100644 index fbc30e2c9e..0000000000 --- a/public/docs/_examples/quickstart/ts/styles.1.css +++ /dev/null @@ -1,14 +0,0 @@ -/* #docregion */ -h1 { - color: #369; - font-family: Arial, Helvetica, sans-serif; - font-size: 250%; -} -body { - margin: 2em; -} - - /* - * See https://github.com/angular/angular.io/blob/master/public/docs/_examples/styles.css - * for the full set of master styles used by the documentation samples - */ diff --git a/public/docs/_examples/quickstart/ts/systemjs.config.1.js b/public/docs/_examples/quickstart/ts/systemjs.config.1.js index 901b8f01d0..63e2109db3 100644 --- a/public/docs/_examples/quickstart/ts/systemjs.config.1.js +++ b/public/docs/_examples/quickstart/ts/systemjs.config.1.js @@ -41,7 +41,7 @@ // Bundled (~40 requests): function packUmd(pkgName) { - packages['@angular/'+pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' }; + packages['@angular/'+pkgName] = { main: 'bundles/' + pkgName + '.umd.js', defaultExtension: 'js' }; } // Most environments should use UMD; some (Karma) need the individual index files diff --git a/public/docs/_examples/router/ts/app/app.routing.1.ts b/public/docs/_examples/router/ts/app/app.routing.1.ts index ccdff404a4..6a420d55ac 100644 --- a/public/docs/_examples/router/ts/app/app.routing.1.ts +++ b/public/docs/_examples/router/ts/app/app.routing.1.ts @@ -1,5 +1,6 @@ // #docplaster // #docregion +import { ModuleWithProviders } from '@angular/core'; // #docregion route-config import { Routes, RouterModule } from '@angular/router'; @@ -36,6 +37,6 @@ export const appRoutingProviders: any[] = [ ]; -export const routing = RouterModule.forRoot(appRoutes); +export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes); // #enddocregion route-config // #enddocregion diff --git a/public/docs/_examples/router/ts/app/app.routing.2.ts b/public/docs/_examples/router/ts/app/app.routing.2.ts index 81c04c86da..1115c9084e 100644 --- a/public/docs/_examples/router/ts/app/app.routing.2.ts +++ b/public/docs/_examples/router/ts/app/app.routing.2.ts @@ -1,5 +1,6 @@ // #docplaster // #docregion +import { ModuleWithProviders } from '@angular/core'; // #docregion route-config import { Routes, RouterModule } from '@angular/router'; @@ -17,5 +18,5 @@ export const appRoutingProviders: any[] = [ ]; -export const routing = RouterModule.forRoot(appRoutes); +export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes); // #enddocregion route-config diff --git a/public/docs/_examples/router/ts/app/app.routing.3.ts b/public/docs/_examples/router/ts/app/app.routing.3.ts index 2eab693570..92930849f0 100644 --- a/public/docs/_examples/router/ts/app/app.routing.3.ts +++ b/public/docs/_examples/router/ts/app/app.routing.3.ts @@ -1,5 +1,6 @@ // #docplaster // #docregion +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { CrisisListComponent } from './crisis-center/crisis-list.component'; @@ -12,4 +13,4 @@ export const appRoutingProviders: any[] = [ ]; -export const routing = RouterModule.forRoot(appRoutes); +export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes); diff --git a/public/docs/_examples/router/ts/app/app.routing.4.ts b/public/docs/_examples/router/ts/app/app.routing.4.ts index 59153e9e53..ff04dd8bfd 100644 --- a/public/docs/_examples/router/ts/app/app.routing.4.ts +++ b/public/docs/_examples/router/ts/app/app.routing.4.ts @@ -1,4 +1,5 @@ // #docregion +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; const appRoutes: Routes = [ @@ -9,4 +10,4 @@ export const appRoutingProviders: any[] = [ ]; -export const routing = RouterModule.forRoot(appRoutes); +export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes); diff --git a/public/docs/_examples/router/ts/app/app.routing.5.ts b/public/docs/_examples/router/ts/app/app.routing.5.ts index 8334e865a5..ce153c7b1f 100644 --- a/public/docs/_examples/router/ts/app/app.routing.5.ts +++ b/public/docs/_examples/router/ts/app/app.routing.5.ts @@ -1,4 +1,5 @@ // #docregion +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { loginRoutes, @@ -12,4 +13,4 @@ export const appRoutingProviders: any[] = [ authProviders ]; -export const routing = RouterModule.forRoot(appRoutes); +export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes); diff --git a/public/docs/_examples/router/ts/app/app.routing.6.ts b/public/docs/_examples/router/ts/app/app.routing.6.ts index 33465b837b..ceee844f0e 100644 --- a/public/docs/_examples/router/ts/app/app.routing.6.ts +++ b/public/docs/_examples/router/ts/app/app.routing.6.ts @@ -1,4 +1,5 @@ // #docregion +import { ModuleWithProviders } from '@angular/core'; // #docregion import-router import { Routes, RouterModule } from '@angular/router'; // #enddocregion import-router @@ -32,7 +33,7 @@ export const appRoutingProviders: any[] = [ CanDeactivateGuard ]; -export const routing = RouterModule.forRoot(appRoutes); +export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes); // #enddocregion /* A link parameters array diff --git a/public/docs/_examples/router/ts/app/app.routing.ts b/public/docs/_examples/router/ts/app/app.routing.ts index 1e320cffea..bf456cba9a 100644 --- a/public/docs/_examples/router/ts/app/app.routing.ts +++ b/public/docs/_examples/router/ts/app/app.routing.ts @@ -1,4 +1,5 @@ // #docregion +import { ModuleWithProviders } from '@angular/core'; // #docregion import-router import { Routes, RouterModule } from '@angular/router'; // #enddocregion import-router @@ -32,4 +33,4 @@ export const appRoutingProviders: any[] = [ CanDeactivateGuard ]; -export const routing = RouterModule.forRoot(appRoutes); +export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes); diff --git a/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.1.ts b/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.1.ts index 0d53587aa4..7c7b913c31 100644 --- a/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.1.ts +++ b/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.1.ts @@ -1,4 +1,5 @@ // #docregion +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { CrisisDetailComponent } from './crisis-detail.component'; @@ -17,5 +18,5 @@ const crisisCenterRoutes: Routes = [ } ]; -export const crisisCenterRouting = RouterModule.forChild(crisisCenterRoutes); +export const crisisCenterRouting: ModuleWithProviders = RouterModule.forChild(crisisCenterRoutes); // #enddocregion routes diff --git a/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.2.ts b/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.2.ts index a95ab751f3..07dcf64c81 100644 --- a/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.2.ts +++ b/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.2.ts @@ -1,4 +1,5 @@ // #docregion +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { CrisisDetailComponent } from './crisis-detail.component'; @@ -24,5 +25,5 @@ const crisisCenterRoutes: Routes = [ } ]; -export const crisisCenterRouting = RouterModule.forChild(crisisCenterRoutes); +export const crisisCenterRouting: ModuleWithProviders = RouterModule.forChild(crisisCenterRoutes); // #enddocregion routes diff --git a/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.3.ts b/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.3.ts index 8d92662132..77cddebf0e 100644 --- a/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.3.ts +++ b/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.3.ts @@ -1,5 +1,6 @@ // #docplaster // #docregion +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { CrisisDetailComponent } from './crisis-detail.component'; @@ -38,7 +39,7 @@ const crisisCenterRoutes: Routes = [ } ]; -export const crisisCenterRouting = RouterModule.forChild(crisisCenterRoutes); +export const crisisCenterRouting: ModuleWithProviders = RouterModule.forChild(crisisCenterRoutes); // #enddocregion /* diff --git a/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.4.ts b/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.4.ts index fa5d1e887c..e21767ecb6 100644 --- a/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.4.ts +++ b/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.4.ts @@ -1,5 +1,6 @@ // #docplaster // #docregion +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { CrisisDetailComponent } from './crisis-detail.component'; @@ -40,7 +41,7 @@ const crisisCenterRoutes: Routes = [ } ]; -export const crisisCenterRouting = RouterModule.forChild(crisisCenterRoutes); +export const crisisCenterRouting: ModuleWithProviders = RouterModule.forChild(crisisCenterRoutes); // #enddocregion /* diff --git a/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.5.ts b/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.5.ts index cb7cda5d31..a6fbb5bddf 100644 --- a/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.5.ts +++ b/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.5.ts @@ -1,5 +1,6 @@ // #docplaster // #docregion +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { CrisisCenterComponent } from './crisis-center.component'; @@ -49,4 +50,4 @@ const crisisCenterRoutes: Routes = [ } ]; -export const crisisCenterRouting = RouterModule.forChild(crisisCenterRoutes); +export const crisisCenterRouting: ModuleWithProviders = RouterModule.forChild(crisisCenterRoutes); diff --git a/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.ts b/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.ts index 2d044f9de9..77bc573718 100644 --- a/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.ts +++ b/public/docs/_examples/router/ts/app/crisis-center/crisis-center.routing.ts @@ -1,5 +1,6 @@ // #docplaster // #docregion +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { CrisisCenterComponent } from './crisis-center.component'; @@ -45,6 +46,6 @@ const crisisCenterRoutes: Routes = [ } ]; -export const crisisCenterRouting = RouterModule.forChild(crisisCenterRoutes); +export const crisisCenterRouting: ModuleWithProviders = RouterModule.forChild(crisisCenterRoutes); // #enddocregion lazy-load-crisis-center // #enddocregion diff --git a/public/docs/_examples/router/ts/app/heroes/heroes.routing.ts b/public/docs/_examples/router/ts/app/heroes/heroes.routing.ts index 89270ec492..4831fdd97b 100644 --- a/public/docs/_examples/router/ts/app/heroes/heroes.routing.ts +++ b/public/docs/_examples/router/ts/app/heroes/heroes.routing.ts @@ -1,4 +1,5 @@ // #docregion +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { HeroListComponent } from './hero-list.component'; @@ -11,5 +12,5 @@ const heroesRoutes: Routes = [ // #enddocregion hero-detail-route ]; -export const heroesRouting = RouterModule.forChild(heroesRoutes); +export const heroesRouting: ModuleWithProviders = RouterModule.forChild(heroesRoutes); // #enddocregion diff --git a/public/docs/_examples/router/ts/app/main.ts b/public/docs/_examples/router/ts/app/main.ts index ba9421d573..961a226688 100644 --- a/public/docs/_examples/router/ts/app/main.ts +++ b/public/docs/_examples/router/ts/app/main.ts @@ -1,6 +1,6 @@ // #docregion -import { browserDynamicPlatform } from '@angular/platform-browser-dynamic'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { AppModule } from './app.module'; -browserDynamicPlatform().bootstrapModule(AppModule); +platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/public/docs/_examples/server-communication/dart/pubspec.yaml b/public/docs/_examples/server-communication/dart/pubspec.yaml index 3d8e06cbe0..1d381b2288 100644 --- a/public/docs/_examples/server-communication/dart/pubspec.yaml +++ b/public/docs/_examples/server-communication/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 http: ^0.11.3+3 diff --git a/public/docs/_examples/server-communication/ts/app/app.module.1.ts b/public/docs/_examples/server-communication/ts/app/app.module.1.ts index 51e52573cb..51329e31cb 100644 --- a/public/docs/_examples/server-communication/ts/app/app.module.1.ts +++ b/public/docs/_examples/server-communication/ts/app/app.module.1.ts @@ -14,7 +14,7 @@ import { AppComponent } from './app.component'; JsonpModule ], declarations: [ AppComponent ], - bootstrap: [ AppComponent ] + bootstrap: [ AppComponent ] }) export class AppModule { } diff --git a/public/docs/_examples/server-communication/ts/app/app.module.ts b/public/docs/_examples/server-communication/ts/app/app.module.ts index 528110661b..95490f2b1d 100644 --- a/public/docs/_examples/server-communication/ts/app/app.module.ts +++ b/public/docs/_examples/server-communication/ts/app/app.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; -import { HttpModule, JsonpModule, XHRBackend } from '@angular/http'; +import { HttpModule, JsonpModule } from '@angular/http'; -import { InMemoryBackendService, SEED_DATA } from 'angular2-in-memory-web-api'; -import { HeroData } from './hero-data'; -import { AppComponent } from './app.component'; +import { InMemoryWebApiModule } from 'angular2-in-memory-web-api'; +import { HeroData } from './hero-data'; + +import { AppComponent } from './app.component'; import { HeroListComponent } from './toh/hero-list.component'; import { HeroListPromiseComponent } from './toh/hero-list.component.promise'; @@ -19,11 +20,10 @@ import { WikiSmartComponent } from './wiki/wiki-smart.component'; BrowserModule, FormsModule, HttpModule, - JsonpModule - ], - providers: [ - { provide: XHRBackend, useClass: InMemoryBackendService }, // in-mem server - { provide: SEED_DATA, useClass: HeroData } // in-mem server data + JsonpModule, + // #docregion in-mem-web-api + InMemoryWebApiModule.forRoot(HeroData) + // #enddocregion in-mem-web-api ], declarations: [ AppComponent, diff --git a/public/docs/_examples/server-communication/ts/app/hero-data.ts b/public/docs/_examples/server-communication/ts/app/hero-data.ts index ad10b464c7..e5e0bab986 100644 --- a/public/docs/_examples/server-communication/ts/app/hero-data.ts +++ b/public/docs/_examples/server-communication/ts/app/hero-data.ts @@ -1,5 +1,6 @@ // #docregion -export class HeroData { +import { InMemoryDbService } from 'angular2-in-memory-web-api'; +export class HeroData implements InMemoryDbService { createDb() { let heroes = [ { id: '1', name: 'Windstorm' }, diff --git a/public/docs/_examples/structural-directives/dart/pubspec.yaml b/public/docs/_examples/structural-directives/dart/pubspec.yaml index daba4aa174..3a8e521ee9 100644 --- a/public/docs/_examples/structural-directives/dart/pubspec.yaml +++ b/public/docs/_examples/structural-directives/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/style-guide/ts/app/app.routes.ts b/public/docs/_examples/style-guide/ts/app/app.routes.ts index 3d5d6b3c15..1fb26f08ea 100644 --- a/public/docs/_examples/style-guide/ts/app/app.routes.ts +++ b/public/docs/_examples/style-guide/ts/app/app.routes.ts @@ -1,4 +1,4 @@ -import { RouterConfig } from '@angular/router'; +import { Routes } from '@angular/router'; import { AppComponent as S0101 } from '../01-01/app'; // import { AppComponent as S0207 } from '../02-07/app'; @@ -27,7 +27,7 @@ import { AppComponent as S0101 } from '../01-01/app'; // import { AppComponent as S0704 } from '../07-04/app'; // import { AppComponent as S0901 } from '../09-01/app'; -export const routes: RouterConfig = [ +export const routes: Routes = [ { path: '', redirectTo: '/01-01', pathMatch: 'full' }, { path: '01-01', component: S0101 }, // { path: '02-07', component: S0207 }, @@ -56,4 +56,3 @@ export const routes: RouterConfig = [ // { path: '07-04', component: S0704 }, // { path: '09-01', component: S0901 }, ]; - diff --git a/public/docs/_examples/style-guide/ts/app/main.ts b/public/docs/_examples/style-guide/ts/app/main.ts index 77e1c29934..6e2dfd46b7 100644 --- a/public/docs/_examples/style-guide/ts/app/main.ts +++ b/public/docs/_examples/style-guide/ts/app/main.ts @@ -2,16 +2,14 @@ import { NgModule } from '@angular/core'; import { browserDynamicPlatform } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; -import { HttpModule, - XHRBackend } from '@angular/http'; +import { HttpModule } from '@angular/http'; +import { InMemoryWebApiModule } from 'angular2-in-memory-web-api'; + import { RouterModule } from '@angular/router'; import { HashLocationStrategy, LocationStrategy } from '@angular/common'; -import { InMemoryBackendService, - SEED_DATA } from 'angular2-in-memory-web-api'; - import 'rxjs/add/operator/map'; import { HeroData } from './hero-data'; @@ -49,6 +47,7 @@ const moduleMetadata = { imports: [ BrowserModule, HttpModule, + InMemoryWebApiModule.forRoot(HeroData), s0101.AppModule, s0207.AppModule, @@ -77,17 +76,16 @@ const moduleMetadata = { s0704.AppModule, s0901.AppModule, + RouterModule.forRoot([ { path: '', redirectTo: '/01-01', pathMatch: 'full' } ], {/* enableTracing: true */}), ], - declarations: [AppComponent], providers: [ - { provide: LocationStrategy, useClass: HashLocationStrategy }, - { provide: XHRBackend, useClass: InMemoryBackendService }, - { provide: SEED_DATA, useClass: HeroData } + { provide: LocationStrategy, useClass: HashLocationStrategy } ], - bootstrap: [ AppComponent ] + declarations: [ AppComponent ], + bootstrap: [ AppComponent ] }; @NgModule(moduleMetadata) diff --git a/public/docs/_examples/styles.css b/public/docs/_examples/styles.css index 62ddfa5121..d7b83f9e81 100644 --- a/public/docs/_examples/styles.css +++ b/public/docs/_examples/styles.css @@ -1,3 +1,4 @@ +/* #docregion , quickstart, toh */ /* Master Styles */ h1 { color: #369; @@ -12,10 +13,12 @@ h2, h3 { body { margin: 2em; } +/* #enddocregion quickstart */ body, input[text], button { color: #888; font-family: Cambria, Georgia; } +/* #enddocregion toh */ a { cursor: pointer; cursor: hand; @@ -135,7 +138,7 @@ nav a.active { margin-right: .8em; border-radius: 4px 0 0 4px; } - +/* #docregion toh */ /* everywhere else */ * { font-family: Arial, Helvetica, sans-serif; diff --git a/public/docs/_examples/systemjs.config.js b/public/docs/_examples/systemjs.config.js index 1921a431c0..2fb97dbfc8 100644 --- a/public/docs/_examples/systemjs.config.js +++ b/public/docs/_examples/systemjs.config.js @@ -40,7 +40,7 @@ // Bundled (~40 requests): function packUmd(pkgName) { - packages['@angular/'+pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' }; + packages['@angular/'+pkgName] = { main: 'bundles/' + pkgName + '.umd.js', defaultExtension: 'js' }; } // Most environments should use UMD; some (Karma) need the individual index files diff --git a/public/docs/_examples/template-syntax/dart/lib/app_component.dart b/public/docs/_examples/template-syntax/dart/lib/app_component.dart index 6d9199c175..6a3def5aa4 100644 --- a/public/docs/_examples/template-syntax/dart/lib/app_component.dart +++ b/public/docs/_examples/template-syntax/dart/lib/app_component.dart @@ -108,8 +108,7 @@ class AppComponent implements OnInit, AfterViewInit { bool onSave([UIEvent event = null]) { HtmlElement el = event?.target; - var evtMsg = - event != null ? ' Event target is ${el.innerHtml}.' : ''; + var evtMsg = event != null ? ' Event target is ${el.innerHtml}.' : ''; alerter('Saved. $evtMsg'); return false; } @@ -126,8 +125,12 @@ class AppComponent implements OnInit, AfterViewInit { } String getStyles(Element el) { - var showStyles = setStyles(); - return JSON.encode(showStyles); + final style = el.style; + final Map styles = {}; + for (var i = 0; i < style.length; i++) { + styles[style.item(i)] = style.getPropertyValue(style.item(i)); + } + return JSON.encode(styles); } Map _previousClasses = {}; @@ -140,8 +143,8 @@ class AppComponent implements OnInit, AfterViewInit { }; // #docregion setClasses // compensate for DevMode (sigh) - if (JSON.encode(_previousClasses) == - JSON.encode(classes)) return _previousClasses; + if (JSON.encode(_previousClasses) == JSON.encode(classes)) + return _previousClasses; _previousClasses = classes; // #enddocregion setClasses return classes; @@ -149,8 +152,8 @@ class AppComponent implements OnInit, AfterViewInit { // #enddocregion setClasses // #docregion setStyles - Map setStyles() { - return { + Map setStyles() { + return { 'font-style': canSave ? 'italic' : 'normal', // italic 'font-weight': !isUnchanged ? 'bold' : 'normal', // normal 'font-size': isSpecial ? '24px' : '8px' // 24px @@ -158,8 +161,27 @@ class AppComponent implements OnInit, AfterViewInit { } // #enddocregion setStyles + // #docregion NgStyle + bool isItalic = false; + bool isBold = false; + String fontSize = 'large'; + + Map setStyle() { + return { + 'font-style': isItalic ? 'italic' : 'normal', + 'font-weight': isBold ? 'bold' : 'normal', + 'font-size': fontSize + }; + } + // #enddocregion NgStyle + String title = 'Template Syntax'; + // #docregion evil-title + String evilTitle = 'Template Syntax'; + // #enddocregion evil-title + String toeChoice; + String toeChooser(Element picker) { List choices = picker.children; for (var i = 0; i < choices.length; i++) { @@ -187,13 +209,16 @@ class AppComponent implements OnInit, AfterViewInit { int heroesNoTrackByChangeCount = 0; int heroesWithTrackByChangeCount = 0; - @ViewChildren('noTrackBy') QueryList childrenNoTrackBy; - @ViewChildren('withTrackBy') QueryList childrenWithTrackBy; + @ViewChildren('noTrackBy') + QueryList childrenNoTrackBy; + @ViewChildren('withTrackBy') + QueryList childrenWithTrackBy; void _detectNgForTrackByEffects() { /// Converts [viewChildren] to a list of [Element]. List _extractChildren(QueryList viewChildren) => - viewChildren.toList()[0].nativeElement.children.toList() as List; + viewChildren.toList()[0].nativeElement.children.toList() + as List; { // Updates 'without TrackBy' statistics. diff --git a/public/docs/_examples/template-syntax/dart/lib/app_component.html b/public/docs/_examples/template-syntax/dart/lib/app_component.html index c7542c3039..9fd72765ed 100644 --- a/public/docs/_examples/template-syntax/dart/lib/app_component.html +++ b/public/docs/_examples/template-syntax/dart/lib/app_component.html @@ -197,13 +197,18 @@ button -Interpolated:
-Property bound: +

is the interpolated image.

+

is the property bound image.

-
The interpolated title is {{title}}
-
+

"{{title}}" is the interpolated title.

+

"" is the property bound title.

+ +

"{{evilTitle}}" is the interpolated evil title.

+

"" is the property bound evil title.

+ + top @@ -409,6 +414,18 @@ bindon-ngModel

NgStyle Binding

+ +
+

Change style of this text!

+ + | + | + + +

Style set to: '{{styleP.style.cssText}}'

+
+ +
This div is x-large. diff --git a/public/docs/_examples/template-syntax/dart/pubspec.yaml b/public/docs/_examples/template-syntax/dart/pubspec.yaml index 92574e0a45..f27859910c 100644 --- a/public/docs/_examples/template-syntax/dart/pubspec.yaml +++ b/public/docs/_examples/template-syntax/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/toh-1/dart/pubspec.yaml b/public/docs/_examples/toh-1/dart/pubspec.yaml index 9657ed659d..da508674f5 100644 --- a/public/docs/_examples/toh-1/dart/pubspec.yaml +++ b/public/docs/_examples/toh-1/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/toh-1/e2e-spec.ts b/public/docs/_examples/toh-1/e2e-spec.ts index 15acf6e434..51a935acab 100644 --- a/public/docs/_examples/toh-1/e2e-spec.ts +++ b/public/docs/_examples/toh-1/e2e-spec.ts @@ -19,7 +19,7 @@ class Hero { let _name = await detail.element(by.css('h2')).getText(); return { id: +_id.substr(_id.indexOf(' ') + 1), - name: _name.substr(0, _name.indexOf(' ')) + name: _name.substr(0, _name.lastIndexOf(' ')) }; } } diff --git a/public/docs/_examples/toh-2/dart/pubspec.yaml b/public/docs/_examples/toh-2/dart/pubspec.yaml index 9657ed659d..da508674f5 100644 --- a/public/docs/_examples/toh-2/dart/pubspec.yaml +++ b/public/docs/_examples/toh-2/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/toh-2/e2e-spec.ts b/public/docs/_examples/toh-2/e2e-spec.ts index 256ffbb5d7..617ca38a1f 100644 --- a/public/docs/_examples/toh-2/e2e-spec.ts +++ b/public/docs/_examples/toh-2/e2e-spec.ts @@ -31,7 +31,7 @@ class Hero { let _name = await detail.element(by.css('h2')).getText(); return { id: +_id.substr(_id.indexOf(' ') + 1), - name: _name.substr(0, _name.indexOf(' ')) + name: _name.substr(0, _name.lastIndexOf(' ')) }; } } diff --git a/public/docs/_examples/toh-2/ts-snippets/app.component.snippets.pt2.ts b/public/docs/_examples/toh-2/ts-snippets/app.component.snippets.pt2.ts index 10475a0954..801c550130 100644 --- a/public/docs/_examples/toh-2/ts-snippets/app.component.snippets.pt2.ts +++ b/public/docs/_examples/toh-2/ts-snippets/app.component.snippets.pt2.ts @@ -40,7 +40,7 @@ // #enddocregion ng-if // #docregion hero-array-1 -public heroes = HEROES; +heroes = HEROES; // #enddocregion hero-array-1 // #docregion heroes-template-1 diff --git a/public/docs/_examples/toh-2/ts/app/app.component.ts b/public/docs/_examples/toh-2/ts/app/app.component.ts index 5d10fc55a9..3e7c86f150 100644 --- a/public/docs/_examples/toh-2/ts/app/app.component.ts +++ b/public/docs/_examples/toh-2/ts/app/app.component.ts @@ -102,6 +102,8 @@ export class AppComponent { // #enddocregion selected-hero // #docregion on-select - onSelect(hero: Hero) { this.selectedHero = hero; } + onSelect(hero: Hero): void { + this.selectedHero = hero; + } // #enddocregion on-select } diff --git a/public/docs/_examples/toh-3/dart/pubspec.yaml b/public/docs/_examples/toh-3/dart/pubspec.yaml index 9657ed659d..da508674f5 100644 --- a/public/docs/_examples/toh-3/dart/pubspec.yaml +++ b/public/docs/_examples/toh-3/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/toh-3/e2e-spec.ts b/public/docs/_examples/toh-3/e2e-spec.ts index 070dd69ebd..0f9c747b90 100644 --- a/public/docs/_examples/toh-3/e2e-spec.ts +++ b/public/docs/_examples/toh-3/e2e-spec.ts @@ -31,7 +31,7 @@ class Hero { let _name = await detail.element(by.css('h2')).getText(); return { id: +_id.substr(_id.indexOf(' ') + 1), - name: _name.substr(0, _name.indexOf(' ')) + name: _name.substr(0, _name.lastIndexOf(' ')) }; } } diff --git a/public/docs/_examples/toh-3/ts/app/app.component.ts b/public/docs/_examples/toh-3/ts/app/app.component.ts index fe5a5b98ad..022efc31eb 100644 --- a/public/docs/_examples/toh-3/ts/app/app.component.ts +++ b/public/docs/_examples/toh-3/ts/app/app.component.ts @@ -89,5 +89,7 @@ export class AppComponent { heroes = HEROES; selectedHero: Hero; - onSelect(hero: Hero) { this.selectedHero = hero; } + onSelect(hero: Hero): void { + this.selectedHero = hero; + } } diff --git a/public/docs/_examples/toh-4/dart/pubspec.yaml b/public/docs/_examples/toh-4/dart/pubspec.yaml index 9657ed659d..da508674f5 100644 --- a/public/docs/_examples/toh-4/dart/pubspec.yaml +++ b/public/docs/_examples/toh-4/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/toh-4/e2e-spec.ts b/public/docs/_examples/toh-4/e2e-spec.ts index 8f7852a3e3..8c109167af 100644 --- a/public/docs/_examples/toh-4/e2e-spec.ts +++ b/public/docs/_examples/toh-4/e2e-spec.ts @@ -31,7 +31,7 @@ class Hero { let _name = await detail.element(by.css('h2')).getText(); return { id: +_id.substr(_id.indexOf(' ') + 1), - name: _name.substr(0, _name.indexOf(' ')) + name: _name.substr(0, _name.lastIndexOf(' ')) }; } } diff --git a/public/docs/_examples/toh-4/ts/app/app.component.1.ts b/public/docs/_examples/toh-4/ts/app/app.component.1.ts index 5a0a4d0524..675c7a64d0 100644 --- a/public/docs/_examples/toh-4/ts/app/app.component.1.ts +++ b/public/docs/_examples/toh-4/ts/app/app.component.1.ts @@ -7,7 +7,7 @@ import { Component } from '@angular/core'; import { Hero } from './hero'; // #docregion hero-service-import -import { HeroService } from './hero.service.1'; +import { HeroService } from './hero.service.2'; // #enddocregion hero-service-import // Testable but never shown @@ -41,7 +41,7 @@ export class AppComponent implements OnInit { constructor(private heroService: HeroService) { } // #enddocregion ctor // #docregion getHeroes - getHeroes() { + getHeroes(): void { // #docregion get-heroes this.heroes = this.heroService.getHeroes(); // #enddocregion get-heroes @@ -50,7 +50,7 @@ export class AppComponent implements OnInit { // #docregion ng-on-init // #docregion on-init - ngOnInit() { + ngOnInit(): void { // #enddocregion on-init this.getHeroes(); // #docregion on-init @@ -58,6 +58,8 @@ export class AppComponent implements OnInit { // #enddocregion on-init // #enddocregion ng-on-init - onSelect(hero: Hero) { this.selectedHero = hero; } + onSelect(hero: Hero): void { + this.selectedHero = hero; + } // #docregion on-init } diff --git a/public/docs/_examples/toh-4/ts/app/app.component.ts b/public/docs/_examples/toh-4/ts/app/app.component.ts index 00bee85659..b16acb8375 100644 --- a/public/docs/_examples/toh-4/ts/app/app.component.ts +++ b/public/docs/_examples/toh-4/ts/app/app.component.ts @@ -82,14 +82,16 @@ export class AppComponent implements OnInit { constructor(private heroService: HeroService) { } // #docregion get-heroes - getHeroes() { + getHeroes(): void { this.heroService.getHeroes().then(heroes => this.heroes = heroes); } // #enddocregion get-heroes - ngOnInit() { + ngOnInit(): void { this.getHeroes(); } - onSelect(hero: Hero) { this.selectedHero = hero; } + onSelect(hero: Hero): void { + this.selectedHero = hero; + } } diff --git a/public/docs/_examples/toh-4/ts/app/hero.service.1.ts b/public/docs/_examples/toh-4/ts/app/hero.service.1.ts index 5a15d5c285..15e4c44285 100644 --- a/public/docs/_examples/toh-4/ts/app/hero.service.1.ts +++ b/public/docs/_examples/toh-4/ts/app/hero.service.1.ts @@ -1,19 +1,25 @@ // #docplaster // #docregion -// #docregion empty-class +// #docregion empty-class, full import { Injectable } from '@angular/core'; // #enddocregion empty-class +import { Hero } from './hero'; import { HEROES } from './mock-heroes'; // #docregion empty-class, getHeroes-stub @Injectable() export class HeroService { - // #enddocregion empty-class - getHeroes() { - // #enddocregion getHeroes-stub - return HEROES; - // #docregion getHeroes-stub + // #enddocregion empty-class, getHeroes-stub, full + /* + // #docregion getHeroes-stub + getHeroes(): void { } - // #docregion empty-class + // #enddocregion getHeroes-stub + */ + // #docregion full + getHeroes(): Hero[] { + return HEROES; + } + // #docregion empty-class, getHeroes-stub } diff --git a/public/docs/_examples/toh-4/ts/app/hero.service.2.ts b/public/docs/_examples/toh-4/ts/app/hero.service.2.ts new file mode 100644 index 0000000000..d14fe02410 --- /dev/null +++ b/public/docs/_examples/toh-4/ts/app/hero.service.2.ts @@ -0,0 +1,13 @@ +// #docregion +import { Injectable } from '@angular/core'; + +import { Hero } from './hero'; +import { HEROES } from './mock-heroes'; + +@Injectable() +export class HeroService { + + getHeroes(): Hero[] { + return HEROES; + } +} diff --git a/public/docs/_examples/toh-4/ts/app/hero.service.ts b/public/docs/_examples/toh-4/ts/app/hero.service.ts index 87eb9ec673..01272c1395 100644 --- a/public/docs/_examples/toh-4/ts/app/hero.service.ts +++ b/public/docs/_examples/toh-4/ts/app/hero.service.ts @@ -9,14 +9,14 @@ import { HEROES } from './mock-heroes'; @Injectable() export class HeroService { // #docregion get-heroes - getHeroes() { + getHeroes(): Promise { return Promise.resolve(HEROES); } // #enddocregion get-heroes, just-get-heroes // #enddocregion // See the "Take it slow" appendix // #docregion get-heroes-slowly - getHeroesSlowly() { + getHeroesSlowly(): Promise { return new Promise(resolve => setTimeout(() => resolve(HEROES), 2000) // 2 seconds ); diff --git a/public/docs/_examples/toh-5/dart/lib/app_component.dart b/public/docs/_examples/toh-5/dart/lib/app_component.dart index ecf2bf4f3c..ba1ed39c88 100644 --- a/public/docs/_examples/toh-5/dart/lib/app_component.dart +++ b/public/docs/_examples/toh-5/dart/lib/app_component.dart @@ -1,18 +1,18 @@ // #docplaster // #docregion import 'package:angular2/core.dart'; +// #docregion import-router import 'package:angular2/router.dart'; +// #enddocregion import-router -import 'package:angular2_tour_of_heroes/heroes_component.dart'; -import 'package:angular2_tour_of_heroes/hero_service.dart'; -import 'package:angular2_tour_of_heroes/dashboard_component.dart'; -// #docregion hero-detail-import -import 'package:angular2_tour_of_heroes/hero_detail_component.dart'; -// #enddocregion hero-detail-import +import 'dashboard_component.dart'; +import 'hero_detail_component.dart'; +import 'hero_service.dart'; +import 'heroes_component.dart'; @Component( selector: 'my-app', - // #docregion template + // #docregion template, template-v3 template: '''

{{title}}

''', - // #enddocregion template - // #docregion style-urls + // #enddocregion template, template-v3 + // #docregion styleUrls styleUrls: const ['app_component.css'], - // #enddocregion style-urls + // #enddocregion styleUrls + // #docregion directives-and-providers directives: const [ROUTER_DIRECTIVES], providers: const [HeroService, ROUTER_PROVIDERS]) +// #enddocregion directives-and-providers +// #docregion heroes @RouteConfig(const [ - // #docregion dashboard-route + // #enddocregion heroes + // #docregion dashboard const Route( path: '/dashboard', name: 'Dashboard', component: DashboardComponent, useAsDefault: true), - // #enddocregion dashboard-route - // #docregion hero-detail-route + // #enddocregion dashboard + // #docregion hero-detail const Route( path: '/detail/:id', name: 'HeroDetail', component: HeroDetailComponent), - // #enddocregion hero-detail-route + // #enddocregion hero-detail + // #docregion heroes const Route(path: '/heroes', name: 'Heroes', component: HeroesComponent) ]) +// #enddocregion heroes class AppComponent { String title = 'Tour of Heroes'; } diff --git a/public/docs/_examples/toh-5/dart/lib/app_component_1.dart b/public/docs/_examples/toh-5/dart/lib/app_component_1.dart index 880974b28f..8455181dbc 100644 --- a/public/docs/_examples/toh-5/dart/lib/app_component_1.dart +++ b/public/docs/_examples/toh-5/dart/lib/app_component_1.dart @@ -1,25 +1,40 @@ // #docplaster -// #docregion +// #docregion , v2 import 'package:angular2/core.dart'; -// #enddocregion -import 'package:angular2/router.dart'; // for testing only +// #enddocregion , +// #docregion v2 +import 'package:angular2/router.dart'; // #docregion import 'hero_service.dart'; import 'heroes_component.dart'; +// #enddocregion v2 @Component( selector: 'my-app', template: '''

{{title}}

''', directives: const [HeroesComponent], - providers: const [ - // #enddocregion - ROUTER_PROVIDERS, - // #docregion - HeroService - ]) + providers: const [HeroService]) +// #enddocregion , +class Bogus {} + +// #docregion v2 +@Component( + selector: 'my-app', + // #docregion template-v2 + template: ''' +

{{title}}

+ Heroes + ''', + // #enddocregion template-v2 + directives: const [ROUTER_DIRECTIVES], + providers: const [HeroService, ROUTER_PROVIDERS]) +@RouteConfig(const [ + const Route(path: '/heroes', name: 'Heroes', component: HeroesComponent) +]) +// #docregion , class AppComponent { String title = 'Tour of Heroes'; } diff --git a/public/docs/_examples/toh-5/dart/lib/app_component_2.dart b/public/docs/_examples/toh-5/dart/lib/app_component_2.dart deleted file mode 100644 index 024c2b6ac9..0000000000 --- a/public/docs/_examples/toh-5/dart/lib/app_component_2.dart +++ /dev/null @@ -1,31 +0,0 @@ -// #docplaster -// #docregion -import 'package:angular2/core.dart'; -// #docregion import-router -import 'package:angular2/router.dart'; -// #enddocregion import-router - -import 'hero_service.dart'; -import 'heroes_component.dart'; - -@Component( - selector: 'my-app', - // #docregion template - template: ''' -

{{title}}

- Heroes - ''', - // #enddocregion template - // #docregion directives-and-providers - directives: const [ROUTER_DIRECTIVES], - providers: const [ROUTER_PROVIDERS, HeroService] - // #enddocregion directives-and-providers -) -// #docregion route-config -@RouteConfig(const [ - const Route(path: '/heroes', name: 'Heroes', component: HeroesComponent) -]) -// #enddocregion route-config -class AppComponent { - String title = 'Tour of Heroes'; -} diff --git a/public/docs/_examples/toh-5/dart/lib/dashboard_component.dart b/public/docs/_examples/toh-5/dart/lib/dashboard_component.dart index ff0fb8c0d1..8b2f6fe4af 100644 --- a/public/docs/_examples/toh-5/dart/lib/dashboard_component.dart +++ b/public/docs/_examples/toh-5/dart/lib/dashboard_component.dart @@ -12,9 +12,9 @@ import 'hero_service.dart'; @Component( selector: 'my-dashboard', - // #docregion template-url + // #docregion templateUrl templateUrl: 'dashboard_component.html', - // #enddocregion template-url + // #enddocregion templateUrl // #docregion css styleUrls: const ['dashboard_component.css'] // #enddocregion css @@ -35,7 +35,7 @@ class DashboardComponent implements OnInit { heroes = (await _heroService.getHeroes()).skip(1).take(4).toList(); } - // #docregion goto-detail + // #docregion gotoDetail void gotoDetail(Hero hero) { var link = [ 'HeroDetail', @@ -43,5 +43,5 @@ class DashboardComponent implements OnInit { ]; _router.navigate(link); } -// #enddocregion goto-detail +// #enddocregion gotoDetail } diff --git a/public/docs/_examples/toh-5/dart/lib/dashboard_component_2.dart b/public/docs/_examples/toh-5/dart/lib/dashboard_component_2.dart index aa9afb38d7..c5304f572a 100644 --- a/public/docs/_examples/toh-5/dart/lib/dashboard_component_2.dart +++ b/public/docs/_examples/toh-5/dart/lib/dashboard_component_2.dart @@ -22,5 +22,5 @@ class DashboardComponent implements OnInit { heroes = (await _heroService.getHeroes()).skip(1).take(4).toList(); } - gotoDetail() {/* not implemented yet */} + gotoDetail(Hero hero) {/* not implemented yet */} } diff --git a/public/docs/_examples/toh-5/dart/lib/hero_detail_component.dart b/public/docs/_examples/toh-5/dart/lib/hero_detail_component.dart index a6c506a231..a99528cbaa 100644 --- a/public/docs/_examples/toh-5/dart/lib/hero_detail_component.dart +++ b/public/docs/_examples/toh-5/dart/lib/hero_detail_component.dart @@ -1,30 +1,28 @@ // #docplaster // #docregion , v2 +// #docregion added-imports import 'dart:async'; -import 'dart:html'; +import 'dart:html' show window; -// #docregion import-oninit +// #enddocregion added-imports import 'package:angular2/core.dart'; -// #enddocregion import-oninit -// #docregion import-route-params +// #docregion added-imports import 'package:angular2/router.dart'; -// #enddocregion import-route-params +// #enddocregion added-imports import 'hero.dart'; -// #docregion import-hero-service +// #docregion added-imports import 'hero_service.dart'; -// #enddocregion import-hero-service +// #enddocregion added-imports -// #docregion extract-template @Component( selector: 'my-hero-detail', - // #docregion template-url + // #docregion templateUrl templateUrl: 'hero_detail_component.html', - // #enddocregion template-url, v2 + // #enddocregion templateUrl, v2 styleUrls: const ['hero_detail_component.css'] // #docregion v2 ) -// #enddocregion extract-template // #docregion implement class HeroDetailComponent implements OnInit { // #enddocregion implement @@ -36,19 +34,17 @@ class HeroDetailComponent implements OnInit { HeroDetailComponent(this._heroService, this._routeParams); // #enddocregion ctor - // #docregion ng-oninit + // #docregion ngOnInit Future ngOnInit() async { - // #docregion get-id var idString = _routeParams.get('id'); - var id = int.parse(idString, onError: (_) => null); - // #enddocregion get-id + var id = int.parse(idString ?? '', onError: (_) => null); if (id != null) hero = await (_heroService.getHero(id)); } - // #enddocregion ng-oninit + // #enddocregion ngOnInit - // #docregion go-back + // #docregion goBack void goBack() { window.history.back(); } - // #enddocregion go-back + // #enddocregion goBack } diff --git a/public/docs/_examples/toh-5/dart/lib/hero_service.dart b/public/docs/_examples/toh-5/dart/lib/hero_service.dart index e626b38200..b8e04a67c6 100644 --- a/public/docs/_examples/toh-5/dart/lib/hero_service.dart +++ b/public/docs/_examples/toh-5/dart/lib/hero_service.dart @@ -16,8 +16,8 @@ class HeroService { const Duration(seconds: 2), () => mockHeroes); } - // #docregion get-hero + // #docregion getHero Future getHero(int id) async => (await getHeroes()).firstWhere((hero) => hero.id == id); - // #enddocregion get-hero + // #enddocregion getHero } diff --git a/public/docs/_examples/toh-5/dart/lib/heroes_component.dart b/public/docs/_examples/toh-5/dart/lib/heroes_component.dart index 48e1a167bf..e19c3ab3be 100644 --- a/public/docs/_examples/toh-5/dart/lib/heroes_component.dart +++ b/public/docs/_examples/toh-5/dart/lib/heroes_component.dart @@ -6,27 +6,28 @@ import 'package:angular2/core.dart'; import 'package:angular2/router.dart'; import 'hero.dart'; -import 'hero_detail_component.dart'; import 'hero_service.dart'; -// #docregion metadata, heroes-component-renaming +// #docregion metadata, renaming @Component( selector: 'my-heroes', - // #enddocregion heroes-component-renaming + // #enddocregion renaming templateUrl: 'heroes_component.html', - styleUrls: const ['heroes_component.css'], - directives: const [HeroDetailComponent]) -// #docregion heroes-component-renaming -// #enddocregion heroes-component-renaming, metadata -// #docregion class, heroes-component-renaming + styleUrls: const ['heroes_component.css'] +// #docregion renaming +) +// #enddocregion metadata +// #docregion class class HeroesComponent implements OnInit { - // #enddocregion heroes-component-renaming + // #enddocregion renaming final Router _router; final HeroService _heroService; List heroes; Hero selectedHero; + // #docregion renaming HeroesComponent(this._heroService, this._router); + // #enddocregion renaming Future getHeroes() async { heroes = await _heroService.getHeroes(); @@ -44,5 +45,5 @@ class HeroesComponent implements OnInit { 'HeroDetail', {'id': selectedHero.id.toString()} ]); - // #docregion heroes-component-renaming + // #docregion renaming } diff --git a/public/docs/_examples/toh-5/dart/pubspec.yaml b/public/docs/_examples/toh-5/dart/pubspec.yaml index 9657ed659d..da508674f5 100644 --- a/public/docs/_examples/toh-5/dart/pubspec.yaml +++ b/public/docs/_examples/toh-5/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/toh-5/dart/web/styles_1.css b/public/docs/_examples/toh-5/dart/web/styles_1.css deleted file mode 100644 index dee6d5b8ca..0000000000 --- a/public/docs/_examples/toh-5/dart/web/styles_1.css +++ /dev/null @@ -1,24 +0,0 @@ -/* #docregion toh-excerpt */ -/* Master Styles */ -h1 { - color: #369; - font-family: Arial, Helvetica, sans-serif; - font-size: 250%; -} -h2, h3 { - color: #444; - font-family: Arial, Helvetica, sans-serif; - font-weight: lighter; -} -body { - margin: 2em; -} -body, input[text], button { - color: #888; - font-family: Cambria, Georgia; -} -/* . . . */ -/* everywhere else */ -* { - font-family: Arial, Helvetica, sans-serif; -} diff --git a/public/docs/_examples/toh-5/e2e-spec.ts b/public/docs/_examples/toh-5/e2e-spec.ts index e0dc96b63e..2ae0d5b93b 100644 --- a/public/docs/_examples/toh-5/e2e-spec.ts +++ b/public/docs/_examples/toh-5/e2e-spec.ts @@ -1,113 +1,190 @@ /// 'use strict'; -describe('Tutorial', function () { - beforeAll(function () { - browser.get(''); - }); +const expectedH1 = 'Tour of Heroes'; +const expectedTitle = `Angular 2 ${expectedH1}`; +const targetHero = { id: 15, name: 'Magneta' }; +const targetHeroDashboardIndex = 3; +const nameSuffix = 'X'; +const newHeroName = targetHero.name + nameSuffix; - function getPageStruct() { - let hrefEles = element.all(by.css('my-app a')); +type WPromise = webdriver.promise.Promise; + +class Hero { + id: number; + name: string; + + // Factory methods + + // Get hero from s formatted as ' '. + static fromString(s: string): Hero { + return { + id: +s.substr(0, s.indexOf(' ')), + name: s.substr(s.indexOf(' ') + 1), + }; + } + + // Get hero id and name from the given detail element. + static async fromDetail(detail: protractor.ElementFinder): Promise { + // Get hero id from the first
+ let _id = await detail.all(by.css('div')).first().getText(); + // Get name from the h2 + let _name = await detail.element(by.css('h2')).getText(); + return { + id: +_id.substr(_id.indexOf(' ') + 1), + name: _name.substr(0, _name.lastIndexOf(' ')) + }; + } +} + +describe('Tutorial part 5', () => { + + beforeAll(() => browser.get('')); + + function getPageElts() { + let hrefElts = element.all(by.css('my-app a')); return { - hrefs: hrefEles, - myDashboardHref: hrefEles.get(0), - myDashboardParent: element(by.css('my-app my-dashboard')), - topHeroes: element.all(by.css('my-app my-dashboard .module.hero')), + hrefs: hrefElts, - myHeroesHref: hrefEles.get(1), - myHeroesParent: element(by.css('my-app my-heroes')), + myDashboardHref: hrefElts.get(0), + myDashboard: element(by.css('my-app my-dashboard')), + topHeroes: element.all(by.css('my-app my-dashboard > div h4')), + + myHeroesHref: hrefElts.get(1), + myHeroes: element(by.css('my-app my-heroes')), allHeroes: element.all(by.css('my-app my-heroes li')), + selectedHero: element(by.css('my-app li.selected')), + selectedHeroSubview: element(by.css('my-app my-heroes > div')), - heroDetail: element(by.css('my-app my-hero-detail')) + heroDetail: element(by.css('my-app my-hero-detail > div')) }; } - it('should be able to see the start screen', function () { - let page = getPageStruct(); - expect(page.hrefs.count()).toEqual(2, 'should be two dashboard choices'); - expect(page.myDashboardHref.getText()).toEqual('Dashboard'); - expect(page.myHeroesHref.getText()).toEqual('Heroes'); - }); + describe('Initial page', () => { - it('should be able to see dashboard choices', function () { - let page = getPageStruct(); - expect(page.topHeroes.count()).toBe(4, 'should be 4 dashboard hero choices'); - }); + it(`has title '${expectedTitle}'`, () => { + expect(browser.getTitle()).toEqual(expectedTitle); + }); - it('should be able to toggle the views', function () { - let page = getPageStruct(); + it(`has h1 '${expectedH1}'`, () => { + expectHeading(1, expectedH1); + }); - expect(page.myDashboardParent.element(by.css('h3')).getText()).toEqual('Top Heroes'); - page.myHeroesHref.click().then(function() { - expect(page.myDashboardParent.isPresent()).toBe(false, 'should no longer see dashboard element'); - expect(page.allHeroes.count()).toBeGreaterThan(4, 'should be more than 4 heroes shown'); - return page.myDashboardHref.click(); - }).then(function() { - expect(page.myDashboardParent.isPresent()).toBe(true, 'should once again see the dashboard element'); + const expectedViewNames = ['Dashboard', 'Heroes']; + it(`has views ${expectedViewNames}`, () => { + let viewNames = getPageElts().hrefs.map(el => el.getText()); + expect(viewNames).toEqual(expectedViewNames); + }); + + it('has dashboard as the active view', () => { + let page = getPageElts(); + expect(page.myDashboard.isPresent()).toBeTruthy(); }); }); - it('should be able to edit details from "Dashboard" view', function () { - let page = getPageStruct(); - expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be available'); - let heroEle = page.topHeroes.get(3); - let heroDescrEle = heroEle.element(by.css('h4')); - let heroDescr: string; - return heroDescrEle.getText().then(function(text) { - heroDescr = text; - return heroEle.click(); - }).then(function() { - return editDetails(page, heroDescr, '-foo'); - }).then(function() { - expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be back'); - expect(heroDescrEle.getText()).toEqual(heroDescr + '-foo'); + describe('Dashboard tests', () => { + + beforeAll(() => browser.get('')); + + it('has top heroes', () => { + let page = getPageElts(); + expect(page.topHeroes.count()).toEqual(4); }); + + it(`selects and routes to ${targetHero.name} details`, dashboardSelectTargetHero); + + it(`updates hero name (${newHeroName}) in details view`, updateHeroNameInDetailView); + + it(`saves and shows ${newHeroName} in Dashboard`, () => { + element(by.buttonText('Back')).click(); + let targetHeroElt = getPageElts().topHeroes.get(targetHeroDashboardIndex); + expect(targetHeroElt.getText()).toEqual(newHeroName); + }); + }); - it('should be able to edit details from "Heroes" view', function () { - let page = getPageStruct(); - expect(page.myDashboardParent.isPresent()).toBe(true, 'dashboard element should be present'); - let viewDetailsButtonEle = page.myHeroesParent.element(by.cssContainingText('button', 'View Details')); - let heroEle: protractor.ElementFinder; - let heroDescr: string; - page.myHeroesHref.click().then(function() { - expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present'); - expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be present'); - expect(viewDetailsButtonEle.isPresent()).toBe(false, 'viewDetails button should not yet be present'); - heroEle = page.allHeroes.get(2); - return heroEle.getText(); - }).then(function(text) { - // remove leading 'id' from the element - heroDescr = text.substr(text.indexOf(' ') + 1); - return heroEle.click(); - }).then(function() { - expect(viewDetailsButtonEle.isDisplayed()).toBe(true, 'viewDetails button should now be visible'); - return viewDetailsButtonEle.click(); - }).then(function() { - return editDetails(page, heroDescr, '-bar'); - }).then(function() { - expect(page.myHeroesParent.isPresent()).toBe(true, 'myHeroes element should be back'); - expect(heroEle.getText()).toContain(heroDescr + '-bar'); - expect(viewDetailsButtonEle.isPresent()).toBe(false, 'viewDetails button should again NOT be present'); + describe('Heroes tests', () => { + + beforeAll(() => browser.get('')); + + it('can switch to Heroes view', () => { + getPageElts().myHeroesHref.click(); + let page = getPageElts(); + expect(page.myHeroes.isPresent()).toBeTruthy(); + expect(page.allHeroes.count()).toEqual(10, 'number of heroes'); }); + + it(`selects and shows ${targetHero.name} as selected in list`, () => { + getHeroLiEltById(targetHero.id).click(); + let expectedText = `${targetHero.id} ${targetHero.name}`; + expect(getPageElts().selectedHero.getText()).toBe(expectedText); + }); + + it('shows selected hero subview', async () => { + let page = getPageElts(); + let title = page.selectedHeroSubview.element(by.css('h2')).getText(); + let expectedTitle = `${targetHero.name.toUpperCase()} is my hero`; + expect(title).toEqual(expectedTitle); + }); + + it('can route to hero details', async () => { + element(by.buttonText('View Details')).click(); + + let page = getPageElts(); + expect(page.heroDetail.isPresent()).toBeTruthy('shows hero detail'); + let hero = await Hero.fromDetail(page.heroDetail); + expect(hero.id).toEqual(targetHero.id); + expect(hero.name).toEqual(targetHero.name); + }); + + it(`updates hero name (${newHeroName}) in details view`, updateHeroNameInDetailView); + + it(`shows ${newHeroName} in Heroes list`, () => { + element(by.buttonText('Back')).click(); + let expectedText = `${targetHero.id} ${newHeroName}`; + expect(getHeroLiEltById(targetHero.id).getText()).toEqual(expectedText); + }); + }); - function editDetails(page: any, origValue: string, textToAdd: string) { - expect(page.myDashboardParent.isPresent()).toBe(false, 'dashboard element should NOT be present'); - expect(page.myHeroesParent.isPresent()).toBe(false, 'myHeroes element should NOT be present'); - expect(page.heroDetail.isDisplayed()).toBe(true, 'should be able to see hero-details'); - let inputEle = page.heroDetail.element(by.css('input')); - expect(inputEle.isDisplayed()).toBe(true, 'should be able to see the input box'); - let backButtonEle = page.heroDetail.element(by.css('button')); - expect(backButtonEle.isDisplayed()).toBe(true, 'should be able to see the back button'); - let detailTextEle = page.heroDetail.element(by.css('div h2')); - expect(detailTextEle.getText()).toContain(origValue); - return sendKeys(inputEle, textToAdd).then(function () { - expect(detailTextEle.getText()).toContain(origValue + textToAdd); - return backButtonEle.click(); - }); + async function dashboardSelectTargetHero() { + let targetHeroElt = getPageElts().topHeroes.get(targetHeroDashboardIndex); + expect(targetHeroElt.getText()).toEqual(targetHero.name); + targetHeroElt.click(); + + let page = getPageElts(); + expect(page.heroDetail.isPresent()).toBeTruthy('shows hero detail'); + let hero = await Hero.fromDetail(page.heroDetail); + expect(hero.id).toEqual(targetHero.id); + expect(hero.name).toEqual(targetHero.name); + } + + async function updateHeroNameInDetailView() { + // Assumes that the current view is the hero details view. + addToHeroName(nameSuffix); + + let page = getPageElts(); + let hero = await Hero.fromDetail(page.heroDetail); + expect(hero.id).toEqual(targetHero.id); + expect(hero.name).toEqual(newHeroName); } }); + +function addToHeroName(text: string): WPromise { + let input = element(by.css('input')); + return sendKeys(input, text); +} + +function expectHeading(hLevel: number, expectedText: string): void { + let hTag = `h${hLevel}`; + let hText = element(by.css(hTag)).getText(); + expect(hText).toEqual(expectedText, hTag); +}; + +function getHeroLiEltById(id: number) { + let spanForId = element(by.cssContainingText('li span.badge', id.toString())); + return spanForId.element(by.xpath('..')); +} diff --git a/public/docs/_examples/toh-5/ts/app/app.component.1.ts b/public/docs/_examples/toh-5/ts/app/app.component.1.ts index cbdd040437..c9f5db9712 100644 --- a/public/docs/_examples/toh-5/ts/app/app.component.1.ts +++ b/public/docs/_examples/toh-5/ts/app/app.component.1.ts @@ -1,7 +1,8 @@ // #docplaster -// #docregion +// #docregion , v2 import { Component } from '@angular/core'; +// #enddocregion v2 @Component({ selector: 'my-app', template: ` @@ -9,6 +10,33 @@ import { Component } from '@angular/core'; ` }) +// #enddocregion +// #docregion v2 +@Component({ + selector: 'my-app', + // #docregion template-v2 + template: ` +

{{title}}

+ Heroes + + ` + // #enddocregion template-v2 +}) +// #enddocregion +@Component({ + selector: 'my-app', + // #docregion template-v3 + template: ` +

{{title}}

+ + + ` + // #enddocregion template-v3 +}) +// #docregion , v2 export class AppComponent { title = 'Tour of Heroes'; } diff --git a/public/docs/_examples/toh-5/ts/app/app.component.2.ts b/public/docs/_examples/toh-5/ts/app/app.component.2.ts deleted file mode 100644 index 82e5147775..0000000000 --- a/public/docs/_examples/toh-5/ts/app/app.component.2.ts +++ /dev/null @@ -1,17 +0,0 @@ -// #docplaster -// #docregion -import { Component } from '@angular/core'; - -@Component({ - selector: 'my-app', - // #docregion template - template: ` -

{{title}}

- Heroes - - ` - // #enddocregion template -}) -export class AppComponent { - title = 'Tour of Heroes'; -} diff --git a/public/docs/_examples/toh-5/ts/app/app.component.3.ts b/public/docs/_examples/toh-5/ts/app/app.component.3.ts deleted file mode 100644 index 2d1f83853c..0000000000 --- a/public/docs/_examples/toh-5/ts/app/app.component.3.ts +++ /dev/null @@ -1,24 +0,0 @@ -// #docplaster -// #docregion -import { Component } from '@angular/core'; - -@Component({ - selector: 'my-app', - // #docregion template - template: ` -

{{title}}

- - - `, - // #enddocregion template - // #docregion style-urls - styleUrls: ['app/app.component.css'], - // #enddocregion style-urls -}) -export class AppComponent { - title = 'Tour of Heroes'; -} -// #enddocregion diff --git a/public/docs/_examples/toh-5/ts/app/app.component.ts b/public/docs/_examples/toh-5/ts/app/app.component.ts index fbf2279067..12fe3bfd52 100644 --- a/public/docs/_examples/toh-5/ts/app/app.component.ts +++ b/public/docs/_examples/toh-5/ts/app/app.component.ts @@ -1,4 +1,3 @@ -// #docplaster // #docregion import { Component } from '@angular/core'; @@ -14,9 +13,9 @@ import { Component } from '@angular/core'; `, // #enddocregion template - // #docregion style-urls + // #docregion styleUrls styleUrls: ['app/app.component.css'], - // #enddocregion style-urls + // #enddocregion styleUrls }) export class AppComponent { title = 'Tour of Heroes'; diff --git a/public/docs/_examples/toh-5/ts/app/app.module.1.ts b/public/docs/_examples/toh-5/ts/app/app.module.1.ts index 473ca08fb8..e1cda9b620 100644 --- a/public/docs/_examples/toh-5/ts/app/app.module.1.ts +++ b/public/docs/_examples/toh-5/ts/app/app.module.1.ts @@ -3,11 +3,10 @@ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; -import { AppComponent } from './app.component'; - -import { HeroesComponent } from './heroes.component'; - -import { HeroService } from './hero.service'; +import { AppComponent } from './app.component'; +import { HeroDetailComponent } from './hero-detail.component'; +import { HeroesComponent } from './heroes.component'; +import { HeroService } from './hero.service'; @NgModule({ imports: [ @@ -16,6 +15,7 @@ import { HeroService } from './hero.service'; ], declarations: [ AppComponent, + HeroDetailComponent, HeroesComponent ], providers: [ diff --git a/public/docs/_examples/toh-5/ts/app/app.module.2.ts b/public/docs/_examples/toh-5/ts/app/app.module.2.ts deleted file mode 100644 index 1a4ac0f48d..0000000000 --- a/public/docs/_examples/toh-5/ts/app/app.module.2.ts +++ /dev/null @@ -1,30 +0,0 @@ -// #docregion -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { FormsModule } from '@angular/forms'; - -import { AppComponent } from './app.component'; -import { routing } from './app.routing'; - -import { HeroesComponent } from './heroes.component'; - -import { HeroService } from './hero.service'; - -@NgModule({ - imports: [ - BrowserModule, - FormsModule, - routing - ], - declarations: [ - AppComponent, - HeroesComponent - ], - providers: [ - HeroService - ], - bootstrap: [ AppComponent ] -}) -export class AppModule { -} -// #enddocregion diff --git a/public/docs/_examples/toh-5/ts/app/app.module.3.ts b/public/docs/_examples/toh-5/ts/app/app.module.3.ts deleted file mode 100644 index 2eca272b26..0000000000 --- a/public/docs/_examples/toh-5/ts/app/app.module.3.ts +++ /dev/null @@ -1,47 +0,0 @@ -// #docplaster -// #docregion -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { FormsModule } from '@angular/forms'; - -import { AppComponent } from './app.component'; -import { routing } from './app.routing'; - -import { HeroesComponent } from './heroes.component'; -// #docregion dashboard-declaration -import { DashboardComponent } from './dashboard.component'; -// #enddocregion dashboard-declaration -// #docregion hero-detail-declaration -import { HeroDetailComponent } from './hero-detail.component'; -// #enddocregion hero-detail-declaration -import { HeroService } from './hero.service'; - -@NgModule({ - imports: [ - BrowserModule, - FormsModule, - routing - ], -// #docregion dashboard-declaration, hero-detail-declaration - - declarations: [ -// #enddocregion dashboard-declaration, hero-detail-declaration - AppComponent, - HeroesComponent, -// #docregion dashboard-declaration - DashboardComponent, -// #enddocregion dashboard-declaration -// #docregion hero-detail-declaration - HeroDetailComponent -// #enddocregion hero-detail-declaration -// #docregion dashboard-declaration, hero-detail-declaration - ], -// #enddocregion dashboard-declaration, hero-detail-declaration - providers: [ - HeroService - ], - bootstrap: [ AppComponent ] -}) -export class AppModule { -} -// #enddocregion diff --git a/public/docs/_examples/toh-5/ts/app/app.module.ts b/public/docs/_examples/toh-5/ts/app/app.module.ts index 47cc9415bb..67bafebd38 100644 --- a/public/docs/_examples/toh-5/ts/app/app.module.ts +++ b/public/docs/_examples/toh-5/ts/app/app.module.ts @@ -1,16 +1,17 @@ +// #docplaster // #docregion import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; -import { AppComponent } from './app.component'; -import { routing } from './app.routing'; - -import { HeroesComponent } from './heroes.component'; +import { AppComponent } from './app.component'; import { DashboardComponent } from './dashboard.component'; import { HeroDetailComponent } from './hero-detail.component'; - -import { HeroService } from './hero.service'; +import { HeroesComponent } from './heroes.component'; +import { HeroService } from './hero.service'; +// #docregion routing +import { routing } from './app.routing'; +// #docregion routing @NgModule({ imports: [ @@ -18,17 +19,20 @@ import { HeroService } from './hero.service'; FormsModule, routing ], + // #enddocregion routing + // #docregion dashboard, hero-detail declarations: [ AppComponent, - HeroesComponent, DashboardComponent, - HeroDetailComponent + HeroDetailComponent, + HeroesComponent ], + // #enddocregion dashboard, hero-detail providers: [ HeroService ], bootstrap: [ AppComponent ] + // #docregion routing }) export class AppModule { } -// #enddocregion diff --git a/public/docs/_examples/toh-5/ts/app/app.routing.1.ts b/public/docs/_examples/toh-5/ts/app/app.routing.1.ts index 055b26754e..a69db4104b 100644 --- a/public/docs/_examples/toh-5/ts/app/app.routing.1.ts +++ b/public/docs/_examples/toh-5/ts/app/app.routing.1.ts @@ -1,5 +1,5 @@ -// #docregion -// #docregion routing-config +// #docregion , heroes, routing +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { HeroesComponent } from './heroes.component'; @@ -10,8 +10,8 @@ const appRoutes: Routes = [ component: HeroesComponent } ]; -// #enddocregion routing-config +// #enddocregion heroes, routing // #docregion routing-export -export const routing = RouterModule.forRoot(appRoutes); +export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes); // #enddocregion routing-export diff --git a/public/docs/_examples/toh-5/ts/app/app.routing.2.ts b/public/docs/_examples/toh-5/ts/app/app.routing.2.ts deleted file mode 100644 index a75df506e7..0000000000 --- a/public/docs/_examples/toh-5/ts/app/app.routing.2.ts +++ /dev/null @@ -1,36 +0,0 @@ -// #docregion -import { Routes, RouterModule } from '@angular/router'; - -import { DashboardComponent } from './dashboard.component'; -import { HeroesComponent } from './heroes.component'; -// #docregion hero-detail-import -import { HeroDetailComponent } from './hero-detail.component'; -// #enddocregion hero-detail-import - -const appRoutes: Routes = [ - // #docregion redirect-route - { - path: '', - redirectTo: '/dashboard', - pathMatch: 'full' - }, - // #enddocregion redirect-route - // #docregion dashboard-route - { - path: 'dashboard', - component: DashboardComponent - }, - // #enddocregion dashboard-route - // #docregion hero-detail-route - { - path: 'detail/:id', - component: HeroDetailComponent - }, - // #enddocregion hero-detail-route - { - path: 'heroes', - component: HeroesComponent - } -]; - -export const routing = RouterModule.forRoot(appRoutes); diff --git a/public/docs/_examples/toh-5/ts/app/app.routing.ts b/public/docs/_examples/toh-5/ts/app/app.routing.ts index 62071e2567..81f6d05ed2 100644 --- a/public/docs/_examples/toh-5/ts/app/app.routing.ts +++ b/public/docs/_examples/toh-5/ts/app/app.routing.ts @@ -1,30 +1,43 @@ -// #docregion +// #docplaster +// #docregion , heroes +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; -import { DashboardComponent } from './dashboard.component'; -import { HeroesComponent } from './heroes.component'; -// #docregion hero-detail-import -import { HeroDetailComponent } from './hero-detail.component'; -// #enddocregion hero-detail-import +// #enddocregion heroes +import { DashboardComponent } from './dashboard.component'; +// #docregion heroes +import { HeroesComponent } from './heroes.component'; +// #enddocregion heroes +import { HeroDetailComponent } from './hero-detail.component'; +// #docregion heroes const appRoutes: Routes = [ + // #enddocregion heroes + // #docregion redirect { path: '', redirectTo: '/dashboard', pathMatch: 'full' }, + // #enddocregion redirect + // #docregion dashboard { path: 'dashboard', component: DashboardComponent }, + // #enddocregion dashboard + // #docregion hero-detail { path: 'detail/:id', component: HeroDetailComponent }, + // #enddocregion hero-detail + // #docregion heroes { path: 'heroes', component: HeroesComponent } ]; +// #enddocregion heroes -export const routing = RouterModule.forRoot(appRoutes); +export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes); diff --git a/public/docs/_examples/toh-5/ts/app/dashboard.component.2.ts b/public/docs/_examples/toh-5/ts/app/dashboard.component.2.ts index e6b9609ab0..38decd2b50 100644 --- a/public/docs/_examples/toh-5/ts/app/dashboard.component.2.ts +++ b/public/docs/_examples/toh-5/ts/app/dashboard.component.2.ts @@ -17,10 +17,10 @@ export class DashboardComponent implements OnInit { constructor(private heroService: HeroService) { } - ngOnInit() { + ngOnInit(): void { this.heroService.getHeroes() .then(heroes => this.heroes = heroes.slice(1, 5)); } - gotoDetail() { /* not implemented yet */} + gotoDetail(hero: Hero): void { /* not implemented yet */} } diff --git a/public/docs/_examples/toh-5/ts/app/dashboard.component.ts b/public/docs/_examples/toh-5/ts/app/dashboard.component.ts index 6dd4b1abc2..3deb5bc2ec 100644 --- a/public/docs/_examples/toh-5/ts/app/dashboard.component.ts +++ b/public/docs/_examples/toh-5/ts/app/dashboard.component.ts @@ -10,9 +10,9 @@ import { HeroService } from './hero.service'; @Component({ selector: 'my-dashboard', - // #docregion template-url + // #docregion templateUrl templateUrl: 'app/dashboard.component.html', - // #enddocregion template-url + // #enddocregion templateUrl // #docregion css styleUrls: ['app/dashboard.component.css'] // #enddocregion css @@ -29,15 +29,15 @@ export class DashboardComponent implements OnInit { } // #enddocregion ctor - ngOnInit() { + ngOnInit(): void { this.heroService.getHeroes() .then(heroes => this.heroes = heroes.slice(1, 5)); } - // #docregion goto-detail - gotoDetail(hero: Hero) { + // #docregion gotoDetail + gotoDetail(hero: Hero): void { let link = ['/detail', hero.id]; this.router.navigate(link); } - // #enddocregion goto-detail + // #enddocregion gotoDetail } diff --git a/public/docs/_examples/toh-5/ts/app/hero-detail.component.1.ts b/public/docs/_examples/toh-5/ts/app/hero-detail.component.1.ts new file mode 100644 index 0000000000..efbe8ee913 --- /dev/null +++ b/public/docs/_examples/toh-5/ts/app/hero-detail.component.1.ts @@ -0,0 +1,27 @@ +// Imports in comments cause problems when the app is executed +// (some error about 'traceur' missing). Hence this separate file +// is solely for containing the transitory state of the imports. + +// #docregion added-imports +// Keep the Input import for now, we'll remove it later: +import { Component, Input, OnInit } from '@angular/core'; +import { ActivatedRoute, Params } from '@angular/router'; + +import { HeroService } from './hero.service'; +// #enddocregion added-imports + +// Bogus code below this point. It is only here to make lint happy. +import { Hero } from './hero'; + +@Component({}) +export class HeroDetailComponent implements OnInit { + @Input() hero: Hero; + bogus: Params; + + constructor( + private heroService: HeroService, + private route: ActivatedRoute) { + } + + ngOnInit() {} +} diff --git a/public/docs/_examples/toh-5/ts/app/hero-detail.component.ts b/public/docs/_examples/toh-5/ts/app/hero-detail.component.ts index 713d27c9f2..5513904452 100644 --- a/public/docs/_examples/toh-5/ts/app/hero-detail.component.ts +++ b/public/docs/_examples/toh-5/ts/app/hero-detail.component.ts @@ -1,30 +1,22 @@ // #docplaster -// #docregion -// #docregion import-oninit, v2 +// #docregion , v2 import { Component, OnInit } from '@angular/core'; -// #enddocregion import-oninit -// #docregion import-activated-route import { ActivatedRoute, Params } from '@angular/router'; -// #enddocregion import-activated-route import { Hero } from './hero'; -// #docregion import-hero-service import { HeroService } from './hero.service'; -// #enddocregion import-hero-service -// #docregion extract-template @Component({ selector: 'my-hero-detail', - // #docregion template-url + // #docregion templateUrl templateUrl: 'app/hero-detail.component.html', - // #enddocregion template-url, v2 + // #enddocregion templateUrl, v2 styleUrls: ['app/hero-detail.component.css'] // #docregion v2 }) -// #enddocregion extract-template // #docregion implement export class HeroDetailComponent implements OnInit { - // #enddocregion implement +// #enddocregion implement hero: Hero; // #docregion ctor @@ -34,21 +26,19 @@ export class HeroDetailComponent implements OnInit { } // #enddocregion ctor - // #docregion ng-oninit - ngOnInit() { - // #docregion get-id + // #docregion ngOnInit + ngOnInit(): void { this.route.params.forEach((params: Params) => { let id = +params['id']; this.heroService.getHero(id) .then(hero => this.hero = hero); }); - // #enddocregion get-id } - // #enddocregion ng-oninit + // #enddocregion ngOnInit - // #docregion go-back - goBack() { + // #docregion goBack + goBack(): void { window.history.back(); } -// #enddocregion go-back +// #enddocregion goBack } diff --git a/public/docs/_examples/toh-5/ts/app/hero.service.ts b/public/docs/_examples/toh-5/ts/app/hero.service.ts index 900d0da712..67215fb228 100644 --- a/public/docs/_examples/toh-5/ts/app/hero.service.ts +++ b/public/docs/_examples/toh-5/ts/app/hero.service.ts @@ -6,21 +6,21 @@ import { Injectable } from '@angular/core'; @Injectable() export class HeroService { - getHeroes() { + getHeroes(): Promise { return Promise.resolve(HEROES); } // See the "Take it slow" appendix - getHeroesSlowly() { + getHeroesSlowly(): Promise { return new Promise(resolve => setTimeout(() => resolve(HEROES), 2000) // 2 seconds ); } - // #docregion get-hero - getHero(id: number) { + // #docregion getHero + getHero(id: number): Promise { return this.getHeroes() .then(heroes => heroes.find(hero => hero.id === id)); } - // #enddocregion get-hero + // #enddocregion getHero } diff --git a/public/docs/_examples/toh-5/ts/app/heroes.component.ts b/public/docs/_examples/toh-5/ts/app/heroes.component.ts index c0dbd9c8e7..da66bfa7af 100644 --- a/public/docs/_examples/toh-5/ts/app/heroes.component.ts +++ b/public/docs/_examples/toh-5/ts/app/heroes.component.ts @@ -6,18 +6,18 @@ import { Router } from '@angular/router'; import { Hero } from './hero'; import { HeroService } from './hero.service'; -// #docregion heroes-component-renaming, metadata +// #docregion renaming, metadata @Component({ selector: 'my-heroes', - // #enddocregion heroes-component-renaming + // #enddocregion renaming templateUrl: 'app/heroes.component.html', styleUrls: ['app/heroes.component.css'] - // #docregion heroes-component-renaming + // #docregion renaming }) -// #enddocregion heroes-component-renaming, metadata -// #docregion class, heroes-component-renaming +// #enddocregion metadata +// #docregion class export class HeroesComponent implements OnInit { - // #enddocregion heroes-component-renaming + // #enddocregion renaming heroes: Hero[]; selectedHero: Hero; @@ -25,18 +25,20 @@ export class HeroesComponent implements OnInit { private router: Router, private heroService: HeroService) { } - getHeroes() { + getHeroes(): void { this.heroService.getHeroes().then(heroes => this.heroes = heroes); } - ngOnInit() { + ngOnInit(): void { this.getHeroes(); } - onSelect(hero: Hero) { this.selectedHero = hero; } + onSelect(hero: Hero): void { + this.selectedHero = hero; + } - gotoDetail() { + gotoDetail(): void { this.router.navigate(['/detail', this.selectedHero.id]); } - // #docregion heroes-component-renaming + // #docregion renaming } diff --git a/public/docs/_examples/toh-5/ts/styles.1.css b/public/docs/_examples/toh-5/ts/styles.1.css deleted file mode 100644 index dee6d5b8ca..0000000000 --- a/public/docs/_examples/toh-5/ts/styles.1.css +++ /dev/null @@ -1,24 +0,0 @@ -/* #docregion toh-excerpt */ -/* Master Styles */ -h1 { - color: #369; - font-family: Arial, Helvetica, sans-serif; - font-size: 250%; -} -h2, h3 { - color: #444; - font-family: Arial, Helvetica, sans-serif; - font-weight: lighter; -} -body { - margin: 2em; -} -body, input[text], button { - color: #888; - font-family: Cambria, Georgia; -} -/* . . . */ -/* everywhere else */ -* { - font-family: Arial, Helvetica, sans-serif; -} diff --git a/public/docs/_examples/toh-6/dart/lib/dashboard_component.dart b/public/docs/_examples/toh-6/dart/lib/dashboard_component.dart index da965c301c..d23b7f543d 100644 --- a/public/docs/_examples/toh-6/dart/lib/dashboard_component.dart +++ b/public/docs/_examples/toh-6/dart/lib/dashboard_component.dart @@ -1,4 +1,4 @@ -// #docregion , search +// #docregion import 'dart:async'; import 'package:angular2/core.dart'; @@ -6,6 +6,7 @@ import 'package:angular2/router.dart'; import 'hero.dart'; import 'hero_service.dart'; +// #docregion search import 'hero_search_component.dart'; @Component( diff --git a/public/docs/_examples/toh-6/dart/pubspec.yaml b/public/docs/_examples/toh-6/dart/pubspec.yaml index cdb0ce29f1..6f07f46995 100644 --- a/public/docs/_examples/toh-6/dart/pubspec.yaml +++ b/public/docs/_examples/toh-6/dart/pubspec.yaml @@ -7,7 +7,7 @@ environment: sdk: '>=1.13.0 <2.0.0' # #docregion additions dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 # #enddocregion additions browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 diff --git a/public/docs/_examples/toh-6/dart/web/main.dart b/public/docs/_examples/toh-6/dart/web/main.dart index ff344d1a54..7e41d5d227 100644 --- a/public/docs/_examples/toh-6/dart/web/main.dart +++ b/public/docs/_examples/toh-6/dart/web/main.dart @@ -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'; @@ -15,7 +14,7 @@ void main() { // [provide(Client, useFactory: () => new BrowserClient(), deps: [])] ); } -// #enddocregion final +// #enddocregion v2, /* // #docregion v1 import 'package:http/browser_client.dart'; diff --git a/public/docs/_examples/toh-6/ts/app/app.module.1.ts b/public/docs/_examples/toh-6/ts/app/app.module.1.ts deleted file mode 100644 index 6924d5a390..0000000000 --- a/public/docs/_examples/toh-6/ts/app/app.module.1.ts +++ /dev/null @@ -1,44 +0,0 @@ -// #docplaster -// #docregion -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { FormsModule } from '@angular/forms'; - -// Imports for loading & configuring the in-memory web api -import { HttpModule, XHRBackend } from '@angular/http'; - -import { InMemoryBackendService, SEED_DATA } from 'angular2-in-memory-web-api'; -import { InMemoryDataService } from './in-memory-data.service'; - -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'; - -@NgModule({ - imports: [ - BrowserModule, - FormsModule, - routing, - HttpModule - ], - declarations: [ - AppComponent, - HeroesComponent, - DashboardComponent, - HeroDetailComponent - ], - providers: [ - HeroService, - { provide: XHRBackend, useClass: InMemoryBackendService }, // in-mem server - { provide: SEED_DATA, useClass: InMemoryDataService } // in-mem server data - ], - bootstrap: [ AppComponent ] -}) -export class AppModule { -} -// #enddocregion final diff --git a/public/docs/_examples/toh-6/ts/app/app.module.2.ts b/public/docs/_examples/toh-6/ts/app/app.module.2.ts deleted file mode 100644 index 2ec598cd0b..0000000000 --- a/public/docs/_examples/toh-6/ts/app/app.module.2.ts +++ /dev/null @@ -1,44 +0,0 @@ -// #docplaster -// #docregion -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { FormsModule } from '@angular/forms'; -import { HttpModule } from '@angular/http'; - -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'; -// #docregion hero-search-declaration -import { HeroSearchComponent } from './hero-search.component'; -// #enddocregion hero-search-declaration - -import { HeroService } from './hero.service'; - -@NgModule({ - imports: [ - BrowserModule, - FormsModule, - routing, - HttpModule - ], -// #docregion hero-search-declaration - - declarations: [ - AppComponent, - HeroesComponent, - DashboardComponent, - HeroDetailComponent, - HeroSearchComponent - ], -// #enddocregion hero-search-declaration - providers: [ - HeroService - ], - bootstrap: [ AppComponent ] -}) -export class AppModule { -} -// #enddocregion diff --git a/public/docs/_examples/toh-6/ts/app/app.module.ts b/public/docs/_examples/toh-6/ts/app/app.module.ts index 0beff178e0..1712c79371 100644 --- a/public/docs/_examples/toh-6/ts/app/app.module.ts +++ b/public/docs/_examples/toh-6/ts/app/app.module.ts @@ -1,45 +1,53 @@ -// #docregion -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { FormsModule } from '@angular/forms'; +// #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 { InMemoryWebApiModule } from 'angular2-in-memory-web-api'; +import { InMemoryDataService } from './in-memory-data.service'; -import { InMemoryBackendService, SEED_DATA } from 'angular2-in-memory-web-api'; -import { InMemoryDataService } from './in-memory-data.service'; - -import { AppComponent } from './app.component'; -import { routing } from './app.routing'; - -import { HeroesComponent } from './heroes.component'; +// #docregion v1 +import { AppComponent } from './app.component'; import { DashboardComponent } from './dashboard.component'; +import { HeroesComponent } from './heroes.component'; import { HeroDetailComponent } from './hero-detail.component'; +import { HeroService } from './hero.service'; +// #enddocregion v1, v2 import { HeroSearchComponent } from './hero-search.component'; - -import { HeroService } from './hero.service'; +// #docregion v1, v2 +import { routing } from './app.routing'; @NgModule({ imports: [ BrowserModule, FormsModule, - routing, - HttpModule + HttpModule, + // #enddocregion v1 + // #docregion in-mem-web-api + InMemoryWebApiModule.forRoot(InMemoryDataService), + // #enddocregion in-mem-web-api + // #docregion v1 + routing ], + // #docregion search declarations: [ AppComponent, - HeroesComponent, DashboardComponent, HeroDetailComponent, + HeroesComponent, + // #enddocregion v1, v2 HeroSearchComponent + // #docregion v1, v2 ], + // #enddocregion search providers: [ HeroService, - { provide: XHRBackend, useClass: InMemoryBackendService }, // in-mem server - { provide: SEED_DATA, useClass: InMemoryDataService } // in-mem server data ], bootstrap: [ AppComponent ] }) export class AppModule { } -// #enddocregion diff --git a/public/docs/_examples/toh-6/ts/app/app.routing.ts b/public/docs/_examples/toh-6/ts/app/app.routing.ts index c5753a4ee9..7acd3b9863 100644 --- a/public/docs/_examples/toh-6/ts/app/app.routing.ts +++ b/public/docs/_examples/toh-6/ts/app/app.routing.ts @@ -1,4 +1,5 @@ // #docregion +import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { DashboardComponent } from './dashboard.component'; @@ -25,4 +26,4 @@ const appRoutes: Routes = [ } ]; -export const routing = RouterModule.forRoot(appRoutes); +export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes); diff --git a/public/docs/_examples/toh-6/ts/app/dashboard.component.ts b/public/docs/_examples/toh-6/ts/app/dashboard.component.ts index 4a90a4d6bf..dd2e2ef2ce 100644 --- a/public/docs/_examples/toh-6/ts/app/dashboard.component.ts +++ b/public/docs/_examples/toh-6/ts/app/dashboard.component.ts @@ -19,12 +19,12 @@ export class DashboardComponent implements OnInit { private heroService: HeroService) { } - ngOnInit() { + ngOnInit(): void { this.heroService.getHeroes() .then(heroes => this.heroes = heroes.slice(1, 5)); } - gotoDetail(hero: Hero) { + gotoDetail(hero: Hero): void { let link = ['/detail', hero.id]; this.router.navigate(link); } diff --git a/public/docs/_examples/toh-6/ts/app/hero-detail.component.ts b/public/docs/_examples/toh-6/ts/app/hero-detail.component.ts index 062917401e..4329f63a2c 100644 --- a/public/docs/_examples/toh-6/ts/app/hero-detail.component.ts +++ b/public/docs/_examples/toh-6/ts/app/hero-detail.component.ts @@ -27,7 +27,7 @@ export class HeroDetailComponent implements OnInit { } // #docregion ngOnInit - ngOnInit() { + ngOnInit(): void { this.route.params.forEach((params: Params) => { if (params['id'] !== undefined) { let id = +params['id']; @@ -43,7 +43,7 @@ export class HeroDetailComponent implements OnInit { // #enddocregion ngOnInit // #docregion save - save() { + save(): void { this.heroService .save(this.hero) .then(hero => { @@ -54,7 +54,7 @@ export class HeroDetailComponent implements OnInit { } // #enddocregion save // #docregion goBack - goBack(savedHero: Hero = null) { + goBack(savedHero: Hero = null): void { this.close.emit(savedHero); if (this.navigated) { window.history.back(); } } diff --git a/public/docs/_examples/toh-6/ts/app/hero-search.component.ts b/public/docs/_examples/toh-6/ts/app/hero-search.component.ts index 25ada285ac..384002098d 100644 --- a/public/docs/_examples/toh-6/ts/app/hero-search.component.ts +++ b/public/docs/_examples/toh-6/ts/app/hero-search.component.ts @@ -28,11 +28,13 @@ export class HeroSearchComponent implements OnInit { // #docregion searchTerms // Push a search term into the observable stream. - search(term: string) { this.searchTerms.next(term); } + search(term: string): void { + this.searchTerms.next(term); + } // #enddocregion searchTerms // #docregion search - ngOnInit() { + ngOnInit(): void { this.heroes = this.searchTerms .debounceTime(300) // wait for 300ms pause in events .distinctUntilChanged() // ignore if next search term is same as previous @@ -49,7 +51,7 @@ export class HeroSearchComponent implements OnInit { } // #enddocregion search - gotoDetail(hero: Hero) { + gotoDetail(hero: Hero): void { let link = ['/detail', hero.id]; this.router.navigate(link); } diff --git a/public/docs/_examples/toh-6/ts/app/hero-search.service.ts b/public/docs/_examples/toh-6/ts/app/hero-search.service.ts index 95a31707eb..ae2e47670a 100644 --- a/public/docs/_examples/toh-6/ts/app/hero-search.service.ts +++ b/public/docs/_examples/toh-6/ts/app/hero-search.service.ts @@ -1,6 +1,7 @@ // #docregion import { Injectable } from '@angular/core'; import { Http, Response } from '@angular/http'; +import { Observable } from 'rxjs'; import { Hero } from './hero'; @@ -9,7 +10,7 @@ export class HeroSearchService { constructor(private http: Http) {} - search(term: string) { + search(term: string): Observable { return this.http .get(`app/heroes/?name=${term}`) .map((r: Response) => r.json().data as Hero[]); diff --git a/public/docs/_examples/toh-6/ts/app/hero.service.ts b/public/docs/_examples/toh-6/ts/app/hero.service.ts index 04012768be..21d036ad9e 100644 --- a/public/docs/_examples/toh-6/ts/app/hero.service.ts +++ b/public/docs/_examples/toh-6/ts/app/hero.service.ts @@ -1,7 +1,7 @@ // #docplaster // #docregion import { Injectable } from '@angular/core'; -import { Headers, Http } from '@angular/http'; +import { Headers, Http, Response } from '@angular/http'; // #docregion rxjs import 'rxjs/add/operator/toPromise'; @@ -17,7 +17,7 @@ export class HeroService { constructor(private http: Http) { } - getHeroes() { + getHeroes(): Promise { return this.http.get(this.heroesUrl) // #docregion to-promise .toPromise() @@ -31,7 +31,7 @@ export class HeroService { } // #enddocregion getHeroes - getHero(id: number) { + getHero(id: number): Promise { return this.getHeroes() .then(heroes => heroes.find(hero => hero.id === id)); } @@ -46,7 +46,7 @@ export class HeroService { // #enddocregion save // #docregion delete - delete(hero: Hero) { + delete(hero: Hero): Promise { let headers = new Headers(); headers.append('Content-Type', 'application/json'); @@ -75,7 +75,7 @@ export class HeroService { // #docregion put // Update existing Hero - private put(hero: Hero) { + private put(hero: Hero): Promise { let headers = new Headers(); headers.append('Content-Type', 'application/json'); @@ -90,7 +90,7 @@ export class HeroService { // #enddocregion put // #docregion handleError - private handleError(error: any) { + private handleError(error: any): Promise { console.error('An error occurred', error); return Promise.reject(error.message || error); } diff --git a/public/docs/_examples/toh-6/ts/app/heroes.component.ts b/public/docs/_examples/toh-6/ts/app/heroes.component.ts index e5c5ab1c49..b3d17549e8 100644 --- a/public/docs/_examples/toh-6/ts/app/heroes.component.ts +++ b/public/docs/_examples/toh-6/ts/app/heroes.component.ts @@ -24,7 +24,7 @@ export class HeroesComponent implements OnInit { private router: Router, private heroService: HeroService) { } - getHeroes() { + getHeroes(): void { this.heroService .getHeroes() .then(heroes => this.heroes = heroes) @@ -32,19 +32,19 @@ export class HeroesComponent implements OnInit { } // #docregion addHero - addHero() { + addHero(): void { this.addingHero = true; this.selectedHero = null; } - close(savedHero: Hero) { + close(savedHero: Hero): void { this.addingHero = false; if (savedHero) { this.getHeroes(); } } // #enddocregion addHero // #docregion deleteHero - deleteHero(hero: Hero, event: any) { + deleteHero(hero: Hero, event: any): void { event.stopPropagation(); this.heroService .delete(hero) @@ -56,16 +56,16 @@ export class HeroesComponent implements OnInit { } // #enddocregion deleteHero - ngOnInit() { + ngOnInit(): void { this.getHeroes(); } - onSelect(hero: Hero) { + onSelect(hero: Hero): void { this.selectedHero = hero; this.addingHero = false; } - gotoDetail() { + gotoDetail(): void { this.router.navigate(['/detail', this.selectedHero.id]); } } diff --git a/public/docs/_examples/toh-6/ts/app/in-memory-data.service.ts b/public/docs/_examples/toh-6/ts/app/in-memory-data.service.ts index 261795a641..c63151a122 100644 --- a/public/docs/_examples/toh-6/ts/app/in-memory-data.service.ts +++ b/public/docs/_examples/toh-6/ts/app/in-memory-data.service.ts @@ -1,5 +1,6 @@ // #docregion , init -export class InMemoryDataService { +import { InMemoryDbService } from 'angular2-in-memory-web-api'; +export class InMemoryDataService implements InMemoryDbService { createDb() { let heroes = [ {id: 11, name: 'Mr. Nice'}, diff --git a/public/docs/_examples/user-input/dart/pubspec.yaml b/public/docs/_examples/user-input/dart/pubspec.yaml index fa28056488..c56f2d27a4 100644 --- a/public/docs/_examples/user-input/dart/pubspec.yaml +++ b/public/docs/_examples/user-input/dart/pubspec.yaml @@ -5,7 +5,7 @@ version: 0.0.1 environment: sdk: '>=1.13.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.18 + angular2: 2.0.0-beta.20 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/webpack/e2e-spec.ts.disabled b/public/docs/_examples/webpack/e2e-spec.ts similarity index 100% rename from public/docs/_examples/webpack/e2e-spec.ts.disabled rename to public/docs/_examples/webpack/e2e-spec.ts diff --git a/public/docs/_examples/webpack/ts/config/karma-test-shim.js b/public/docs/_examples/webpack/ts/config/karma-test-shim.js index 27fa731f5a..2a6b7f363c 100644 --- a/public/docs/_examples/webpack/ts/config/karma-test-shim.js +++ b/public/docs/_examples/webpack/ts/config/karma-test-shim.js @@ -5,10 +5,10 @@ require('core-js/es6'); require('reflect-metadata'); require('zone.js/dist/zone'); -require('zone.js/dist/long-stack-trace-zone'); -require('zone.js/dist/jasmine-patch'); require('zone.js/dist/async-test'); require('zone.js/dist/fake-async-test'); +require('zone.js/dist/sync-test'); +require('zone.js/dist/proxy-zone'); var appContext = require.context('../src', true, /\.spec\.ts/); @@ -17,7 +17,4 @@ appContext.keys().forEach(appContext); var testing = require('@angular/core/testing'); var browser = require('@angular/platform-browser-dynamic/testing'); -testing.setBaseTestProviders( - browser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, - browser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS -); +testing.TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platformBrowserDynamicTesting()); diff --git a/public/docs/_examples/webpack/ts/config/webpack.test.js b/public/docs/_examples/webpack/ts/config/webpack.test.js index 352e4f6126..147c94dfcd 100644 --- a/public/docs/_examples/webpack/ts/config/webpack.test.js +++ b/public/docs/_examples/webpack/ts/config/webpack.test.js @@ -1,4 +1,6 @@ // #docregion +var helpers = require('./helpers'); + module.exports = { devtool: 'inline-source-map', @@ -23,7 +25,13 @@ module.exports = { }, { test: /\.css$/, + exclude: helpers.root('src', 'app'), loader: 'null' + }, + { + test: /\.css$/, + include: helpers.root('src', 'app'), + loader: 'raw' } ] } diff --git a/public/docs/_examples/webpack/ts/src/app/app.component.spec.ts b/public/docs/_examples/webpack/ts/src/app/app.component.spec.ts index d7d0696aef..a6512a11e7 100644 --- a/public/docs/_examples/webpack/ts/src/app/app.component.spec.ts +++ b/public/docs/_examples/webpack/ts/src/app/app.component.spec.ts @@ -1,21 +1,16 @@ // #docregion -import { - addProviders, - inject, -} from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { AppComponent } from './app.component'; describe('App', () => { beforeEach(() => { - addProviders([ - AppComponent - ]); + TestBed.configureTestingModule({ declarations: [AppComponent]}); }); - it ('should work', inject([AppComponent], (app: AppComponent) => { - // Add real test here - expect(2).toBe(2); - })); + it ('should work', () => { + let fixture = TestBed.createComponent(AppComponent); + expect(fixture.componentInstance instanceof AppComponent).toBe(true, 'should create AppComponent'); + }); }); // #enddocregion diff --git a/public/docs/_examples/webpack/ts/src/main.ts b/public/docs/_examples/webpack/ts/src/main.ts index 0057db95ab..e1d8cbc0fe 100644 --- a/public/docs/_examples/webpack/ts/src/main.ts +++ b/public/docs/_examples/webpack/ts/src/main.ts @@ -1,5 +1,5 @@ // #docregion -import { browserDynamicPlatform } from '@angular/platform-browser-dynamic'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { enableProdMode } from '@angular/core'; import { AppModule } from './app/app.module'; @@ -10,5 +10,5 @@ if (process.env.ENV === 'production') { } // #enddocregion enable-prod -browserDynamicPlatform().bootstrapModule(AppModule); +platformBrowserDynamic().bootstrapModule(AppModule); // #enddocregion diff --git a/public/docs/dart/latest/_data.json b/public/docs/dart/latest/_data.json index a93259c9ab..48138a453b 100644 --- a/public/docs/dart/latest/_data.json +++ b/public/docs/dart/latest/_data.json @@ -3,7 +3,7 @@ "icon": "home", "title": "Angular Docs", "menuTitle": "Docs Home", - "banner": "Welcome to angular.io/dart! The current Angular 2 Dart release is beta.18. Consult the Change Log about recent enhancements, fixes, and breaking changes." + "banner": "Welcome to angular.io/dart! The current Angular 2 Dart release is beta.20. Consult the Change Log about recent enhancements, fixes, and breaking changes." }, "quickstart": { diff --git a/public/docs/dart/latest/_util-fns.jade b/public/docs/dart/latest/_util-fns.jade index 330b0e38f0..a4a0cf461c 100644 --- a/public/docs/dart/latest/_util-fns.jade +++ b/public/docs/dart/latest/_util-fns.jade @@ -20,6 +20,15 @@ include ../../../_includes/_util-fns - var _indexHtmlDir = 'web'; - var _mainDir = 'web'; +//- NgModule related +- var _AppModuleVsAppComp = 'AppComponent' +- var _appModuleTsVsAppCompTs = 'app/app_component.dart' +- var _appModuleTsVsMainTs = 'web/main.dart' +- var _bootstrapModule = 'bootstrap' +- var _moduleVsComp = 'component' +- var _moduleVsRootComp = 'root component' +- var _platformBrowserDynamicVsBootStrap = 'bootstrap' + //- Deprecated mixin liveExampleLink(linkText, exampleUrlPartName) - var text = linkText || '在线例子'; diff --git a/public/docs/dart/latest/glossary.jade b/public/docs/dart/latest/glossary.jade index 673436c805..26feb4d9f3 100644 --- a/public/docs/dart/latest/glossary.jade +++ b/public/docs/dart/latest/glossary.jade @@ -1,35 +1,68 @@ -include _util-fns +extends ../../ts/_cache/glossary.jade -block var-def - - var fragPath='../../ts/latest/_fragments/'; +block includes + include _util-fns -!=partial(fragPath + 'glossary-intro') -!=partial(fragPath + 'glossary-a1') -!=partial(fragPath + 'glossary-a-2') -!=partial(fragPath + 'glossary-b-c') -!=partial(fragPath + 'glossary-d1') -!=partial(fragPath + 'glossary-d2') -!=partial(fragPath + 'glossary-e1') -!=partial(fragPath + 'glossary-e2') -!=partial(fragPath + 'glossary-f-l') -!=partial(fragPath + 'glossary-m1') -//partial(fragPath + 'glossary-m2') not needed in dart -!=partial(fragPath + 'glossary-n-s-1') - -:marked - ## snake_case - -.l-sub-section +block annotation-defn :marked - The practice of writing compound words or phrases such that each word is separated by an - underscore (`_`). - - Library and file names are often spelled in snake_case. Examples include: - `angular2_tour_of_heroes` and `app_component.dart`. - - This form is also known as **underscore case**. + When unqualified, _annotation_ refers to a Dart [metadata + annotation][metadata] (as opposed to, say, a type annotation). A metadata + annotation begins with the character `@`, followed by either a reference + to a compile-time constant (such as [`Component`](#component)) or a call + to a constant constructor. See the [Dart Language Guide][metadata] for + details. -!=partial(fragPath + 'glossary-n-s-2') -!=partial(fragPath + 'glossary-t1') -//partial(fragPath + 'glossary-t2') notneeded in dart -!=partial(fragPath + 'glossary-u-z') + The corresponding term in TypeScript and JavaScript is + [_decorator_](!{docsPath}/ts/latest/glossary.html#decorator). + + [metadata]: https://www.dartlang.org/guides/language/language-tour#metadata + +block bootstrap-defn-top + :marked + We launch an Angular application by "bootstrapping" it with the + [bootstrap][bootstrap] method. The `bootstrap` method identifies an + application's top level "root" [Component](#component) and optionally + registers service [providers](#provider) with the [dependency injection + system](#dependency-injection). + + [bootstrap]: !{docsLatest}/api/angular2.platform.browser/bootstrap.html + +block decorator-defn + :marked + When used in this guide, these JavaScript terms are taken as synonymous with + [annotation](#annotation). + +block module-defn + //- Taken from the Dart Difference in guide/architecture.jade + :marked + In this guide, the term _module_ refers to a Dart compilation unit, such + as a library, or a package. (If a Dart file has no `library` or `part` + directive, then that file itself is a library and thus a compilation + unit.) For more information about compilation units, see + the chapter on "Libraries and Scripts" in the + [Dart Language Specification](https://www.dartlang.org/docs/spec/). + +block routing-component-defn + :marked + A [Component](#component) with an attached router. + + In most cases, the component became attached to a [router](#router) by means + of a `@RouterConfig` #{decorator} that defined routes to views controlled by this component. + + The component's template has a `RouterOutlet` element where it can display views produced by the router. + + It likely has anchor tags or buttons with `RouterLink` directives that users can click to navigate. + +block append snake-case-defn + :marked + Library and file names are often spelled in snake_case. Examples include: + `angular2_tour_of_heroes` and `app_component.dart`. + +block zone-defn + :marked + Zones are a mechanism for encapsulating and intercepting + a Dart application's asynchronous activity. + + To learn more, consult the [zones article][zones]. + + [zones]: https://www.dartlang.org/articles/libraries/zones diff --git a/public/docs/dart/latest/guide/dependency-injection.jade b/public/docs/dart/latest/guide/dependency-injection.jade index c840601347..3e4c5011e3 100644 --- a/public/docs/dart/latest/guide/dependency-injection.jade +++ b/public/docs/dart/latest/guide/dependency-injection.jade @@ -101,7 +101,7 @@ block dart-map-alternative As an alternative to using a configuration `Map`, we can define a custom configuration class: - +makeExample('lib/app_config.dart (alternative config)','config-alt') + +makeExcerpt('lib/app_config.dart (alternative config)','config-alt') :marked Defining a configuration class has a few benefits. One key benefit diff --git a/public/docs/dart/latest/guide/forms.jade b/public/docs/dart/latest/guide/forms.jade index 19b7d09aa5..73651c1092 100644 --- a/public/docs/dart/latest/guide/forms.jade +++ b/public/docs/dart/latest/guide/forms.jade @@ -1,6 +1,5 @@ include ../_util-fns - :marked We’ve all used a form to log in, submit a help request, place an order, book a flight, schedule a meeting, and perform countless other data entry tasks. @@ -30,6 +29,8 @@ include ../_util-fns - How to share information across controls with template reference variables + Run the . + .l-main-section :marked ## Template-driven forms diff --git a/public/docs/dart/latest/guide/glossary.jade b/public/docs/dart/latest/guide/glossary.jade index eeef440cb0..1d2eb49664 100644 --- a/public/docs/dart/latest/guide/glossary.jade +++ b/public/docs/dart/latest/guide/glossary.jade @@ -1,4 +1,4 @@ extends ../glossary block var-def - - var fragPath='../../../ts/latest/_fragments/'; + include ../_util-fns diff --git a/public/docs/dart/latest/guide/lifecycle-hooks.jade b/public/docs/dart/latest/guide/lifecycle-hooks.jade index c67c1fa3f2..f9a87bbada 100644 --- a/public/docs/dart/latest/guide/lifecycle-hooks.jade +++ b/public/docs/dart/latest/guide/lifecycle-hooks.jade @@ -3,9 +3,16 @@ extends ../../../ts/_cache/guide/lifecycle-hooks.jade block includes include ../_util-fns -block optional-interfaces - //- n/a for Dart +block other-angular-subsystems + :marked + The router, for instance, also has its own [router lifecycle + hooks](router.html#router-lifecycle-hooks) that allow us to tap into + specific moments in route navigation. + A parallel can be drawn between `ngOnInit` and `routerOnActivate`. Both are + prefixed so as to avoid collision, and both run right when a component is + being initialized. block tick-methods :marked - The `LoggerService.tick` method, which returns a `Future`, postpones the update one turn of the of the browser's update cycle ... and that's long enough. + The `LoggerService.tick` method, which returns a `Future`, postpones the + update one turn of the of the browser's update cycle ... and that's long enough. diff --git a/public/docs/dart/latest/guide/user-input.jade b/public/docs/dart/latest/guide/user-input.jade index 8f00bc1339..bd73ed73da 100644 --- a/public/docs/dart/latest/guide/user-input.jade +++ b/public/docs/dart/latest/guide/user-input.jade @@ -6,10 +6,12 @@ include ../_util-fns In this chapter we learn to bind to those events using the Angular event binding syntax. + Run the . + :marked ## Binding to user input events - We can use Angular event bindings + We can use [Angular event bindings](./template-syntax.html#event-binding) to respond to [any DOM event](https://developer.mozilla.org/en-US/docs/Web/Events). The syntax is simple. We surround the DOM event name with diff --git a/public/docs/dart/latest/quickstart.jade b/public/docs/dart/latest/quickstart.jade index 8126efc8dc..c9e2f66385 100644 --- a/public/docs/dart/latest/quickstart.jade +++ b/public/docs/dart/latest/quickstart.jade @@ -4,8 +4,10 @@ block includes include _util-fns - var _Install = 'Get' - var _prereq = 'the Dart SDK' - - var _angular_browser_uri = 'package:angular2/platform/browser.dart' - - var _angular_core_uri = 'package:angular2/core.dart' + - var _angular_browser_uri = 'angular2/platform/browser.dart' + - var _angular_core_uri = 'angular2/core.dart' + - var _stepInit = 3 + - var _quickstartSrcURL='https://github.com/angular-examples/quickstart' block setup-tooling :marked @@ -20,9 +22,6 @@ block setup-tooling [DT]: https://www.dartlang.org/tools/ [pub]: https://www.dartlang.org/tools/pub/ -block download-source - // exclude this section from Dart - block package-and-config-files :marked In the project folder just created, create a file named @@ -31,7 +30,7 @@ block package-and-config-files packages as dependencies, as well as the `angular2` transformer. It can also specify other packages and transformers for the app to use, such as [dart_to_js_script_rewriter](https://pub.dartlang.org/packages/dart_to_js_script_rewriter). - Angular 2 is still changing, so provide an exact version: **2.0.0-beta.18**. + Angular 2 is still changing, so provide an exact version: **2.0.0-beta.20**. [pubspec]: https://www.dartlang.org/tools/pub/pubspec.html @@ -59,9 +58,6 @@ block create-main li a #[b folder named #[code web]] li a file named #[code #[+adjExPath('app/main.ts')]] with the following content: -block index-html-commentary-for-ts - //- N/A - block run-app p. We have a few options for running our app. @@ -87,10 +83,10 @@ block build-app in the [proper folders](#wrap-up), and run `pub get`. - .l-verbose-section - h3#section-angular-run-app Building the app (generating JavaScript) - + .l-verbose-section#section-angular-run-app :marked + ### Building the app (generating JavaScript) + Before deploying the app, we need to generate JavaScript files. The `pub build` command makes that easy. @@ -98,11 +94,12 @@ block build-app > pub build Loading source assets... - p. + :marked The generated JavaScript appears, along with supporting files, - under a directory named build. + under a directory named `build`. - h4#angular_transformer Using the Angular transformer + #angular_transformer + h4 Using the Angular transformer p. When generating JavaScript for an Angular app, @@ -124,7 +121,7 @@ block build-app Angular transformer wiki page. - #performance.l-sub-section + .l-sub-section#performance h3 Performance, the transformer, and Angular 2 libraries p. When an app imports bootstrap.dart, @@ -136,7 +133,8 @@ block build-app (entry_points in pubspec.yaml) so that they don't use mirrors. - h4#dart_to_js_script_rewriter Using dart_to_js_script_rewriter + #dart_to_js_script_rewriter + h4 Using dart_to_js_script_rewriter :marked To improve the app's performance, convert the @@ -196,13 +194,10 @@ block project-files quickstart/ts/app/main.ts, quickstart/ts/index.html, quickstart/dart/pubspec.yaml, - quickstart/ts/styles.1.css` - ,null, + quickstart/ts/styles.css`, + ',,,,quickstart', `app/app.component.ts, app/main.ts, index.html, pubspec.yaml, - styles.css`) - -block what-next-ts-overhead - //- N/A + styles.css (excerpt)`) diff --git a/public/docs/dart/latest/tutorial/toh-pt5.jade b/public/docs/dart/latest/tutorial/toh-pt5.jade index 00fe8db972..6be571c148 100644 --- a/public/docs/dart/latest/tutorial/toh-pt5.jade +++ b/public/docs/dart/latest/tutorial/toh-pt5.jade @@ -1,702 +1,168 @@ -include ../_util-fns +extends ../../../ts/_cache/tutorial/toh-pt5 -:marked - # Routing Around the App - We received new requirements for our Tour of Heroes application: - * Add a *Dashboard* view. - * Navigate between the *Heroes* and *Dashboard* views. - * Clicking on a hero in either view navigates to a detail view of the selected hero. - * Clicking a *deep link* in an email opens the detail view for a particular hero. +block includes + include ../_util-fns + - var _appRoutingTsVsAppComp = 'AppComponent' + - var _declsVsDirectives = 'directives' + - var _RoutesVsAtRouteConfig = '@RouteConfig' + - var _RouterModuleVsRouterDirectives = 'ROUTER_DIRECTIVES' + - var _redirectTo = 'useAsDefault' - When we’re done, users will be able to navigate the app like this: -figure.image-display - img(src='/resources/images/devguide/toh/nav-diagram.png' alt="View navigations") -:marked - We'll add Angular’s *Component Router* to our app to satisfy these requirements. -.l-sub-section - :marked - The [Routing and Navigation](../guide/router.html) chapter covers the router in more detail - than we will in this tutorial. - - Run the for this part. - -.l-main-section -:marked - ## Where We Left Off - Before we continue with our Tour of Heroes, let’s verify that we have the following structure after adding our hero service - and hero detail component. If not, we’ll need to go back and follow the previous chapters. - -.filetree +block intro-file-tree + .filetree .file angular2_tour_of_heroes .children - .file lib - .children - .file app_component.dart - .file hero.dart - .file hero_detail_component.dart - .file hero_service.dart - .file mock_heroes.dart - .file web - .children - .file index.html - .file main.dart - .file styles.css - .file pubspec.yaml -:marked - ### Keep the app compiling and running - Open a terminal/console window. - Start the Dart compiler, watch for changes, and start our server by entering the command: + .file lib + .children + .file app_component.dart + .file hero.dart + .file hero_detail_component.dart + .file hero_service.dart + .file mock_heroes.dart + .file web + .children + .file index.html + .file main.dart + .file styles.css + .file pubspec.yaml -code-example(language="bash"). - pub serve - -:marked - The application runs and updates automatically as we continue to build the Tour of Heroes. - - ## Action plan - Here's our plan: - - * Turn `AppComponent` into an application shell that only handles navigation - * Relocate the *Heroes* concerns within the current `AppComponent` to a separate `HeroesComponent` - * Add routing - * Create a new `DashboardComponent` - * Tie the *Dashboard* into the navigation structure - -.l-sub-section +block keep-app-running :marked - *Routing* is another name for *navigation*. The *router* is the mechanism for navigating from view to view. + ### Keep the app compiling and running -.l-main-section -:marked - ## Splitting the *AppComponent* + Open a terminal/console window. + Start the Dart compiler, watch for changes, and start our server by entering the command: - Our current app loads `AppComponent` and immediately displays the list of heroes. + code-example(language="bash"). + pub serve - Our revised app should present a shell with a choice of views (*Dashboard* and *Heroes*) and then default to one of them. +block app-comp-v1 + +makeExcerpt('lib/app_component_1.dart (v1)', '') - The `AppComponent` should only handle navigation. - Let's move the display of *Heroes* out of `AppComponent` and into its own `HeroesComponent`. - - ### *HeroesComponent* - `AppComponent` is already dedicated to *Heroes*. - Instead of moving anything out of `AppComponent`, we'll just rename it `HeroesComponent` - and create a new `AppComponent` shell separately. - - The steps are to rename: - * `app_component.dart` file to `heroes_component.dart` - * `AppComponent` class to `HeroesComponent` - * Selector `my-app` to `my-heroes` - -:marked -+makeExample('toh-5/dart/lib/heroes_component.dart', 'heroes-component-renaming', 'lib/heroes_component.dart (showing renamings only)')(format=".") - -:marked - ## Create *AppComponent* - The new `AppComponent` will be the application shell. - It will have some navigation links at the top and a display area below for the pages we navigate to. - - The initial steps are: - - * create a new file named `app_component.dart`. - * define an `AppComponent` class. - * expose an application `title` property. - * add the `@Component` metadata annotation above the class with a `my-app` selector. - * add a template with `

` tags surrounding a binding to the `title` property. - * add the `` tags to the template so we still see the heroes. - * add the `HeroesComponent` to the `directives` list so Angular recognizes the `` tags. - * add the `HeroService` to the `providers` list because we'll need it in every other view. - * add the supporting `import` statements. - - Our first draft looks like this: -+makeExample('toh-5/dart/lib/app_component_1.dart', null, 'lib/app_component.dart (v1)') -:marked -.callout.is-critical - header Remove HeroService from the HeroesComponent providers +block angular-router :marked - Go back to the `HeroesComponent` and **remove the `HeroService`** from its `providers` list. - We are *promoting* this service from the `HeroesComponent` to the `AppComponent`. - We ***do not want two copies*** of this service at two different levels of our app. -:marked - The app still runs and still displays heroes. - Our refactoring of `AppComponent` into a new `AppComponent` and a `HeroesComponent` worked! - We have done no harm. + The Angular router is a combination of multiple services + (`ROUTER_PROVIDERS`), multiple directives (`ROUTER_DIRECTIVES`), and a + configuration annotation (`RouteConfig`). We'll get them all by importing + the router library: -:marked - ## Add Routing + +makeExcerpt('app/app.component.ts (router imports)', 'import-router') - We're ready to take the next step. - Instead of displaying heroes automatically, we'd like to show them *after* the user clicks a button. - In other words, we'd like to navigate to the list of heroes. - - We'll need the Angular *Component Router*. - - ### Add a base tag - -:marked - First, edit `index.html` and add `` at the top of the `` section. -+makeExample('toh-5/dart/web/index.html', 'base-href', 'index.html (base href)')(format=".") -.callout.is-important - header base href is essential :marked - See the *base href* section of the [Router](../guide/router.html#!#base-href) chapter to learn why this matters. -:marked - ### Make the router available + ### Make the router available - Not all apps need routing, which is why the Angular *Component Router* is in a separate, optional module library. + Not all apps need routing, which is why the Angular *Component Router* is + in a separate, optional library module. - The Angular router is a combination of multiple services (`ROUTER_PROVIDERS`), multiple directives (`ROUTER_DIRECTIVES`), - and a configuration annotation (`RouteConfig`). We'll get them all by importing `router.dart`: -+makeExample('toh-5/dart/lib/app_component_2.dart', 'import-router', 'lib/app_component.dart (router imports)')(format=".") + Like for any service, we make router services available to the application + by adding them to the `providers` list. Let's update the `directives` and + `providers` lists to include the router assets: -:marked - The *Component Router* is a service. Like any service, we have to make it - available to the application by adding it to the `providers` list. + +makeExcerpt('app/app.component.ts (excerpt)', 'directives-and-providers') - Let's update the `directives` and `providers` metadata lists to *include* the router assets. -+makeExample('toh-5/dart/lib/app_component_2.dart', 'directives-and-providers', 'lib/app_component.dart (directives and providers)')(format=".") -:marked - Notice that we also removed the `HeroesComponent` from the `directives` list. - `AppComponent` no longer shows heroes; that will be the router's job. - We'll soon remove `` from the template too. - - ### Add and configure the router - - The `AppComponent` doesn't have a router yet. We'll use the `@RouteConfig` annotation to simultaneously - (a) assign a router to the component and (b) configure that router with *routes*. - - *Routes* tell the router which views to display when a user clicks a link or - pastes a URL into the browser address bar. - - Let's define our first route, a route to the `HeroesComponent`. -+makeExample('toh-5/dart/lib/app_component_2.dart', 'route-config', 'lib/app_component.dart (RouteConfig for heroes)')(format=".") -:marked - `@RouteConfig` takes a list of *route definitions*. - We have only one route definition at the moment but rest assured, we'll add more. - - This *route definition* has three parts: - * **path**: the router matches this route's path to the URL in the browser address bar (`/heroes`). - - * **name**: the official name of the route; it *must* begin with a capital letter to avoid confusion with the *path* (`Heroes`). - - * **component**: the component that the router should create when navigating to this route (`HeroesComponent`). - -.l-sub-section :marked - Learn more about defining routes with @RouteConfig in the [Routing](../guide/router.html) chapter. -:marked - ### Router Outlet + Notice that we also removed the `HeroesComponent` from the `directives` list. + `AppComponent` no longer shows heroes; that will be the router's job. + We'll soon remove `` from the template too. - If we paste the path, `/heroes`, into the browser address bar, - the router should match it to the `'Heroes'` route and display the `HeroesComponent`. - But where? - - We have to ***tell it where*** by adding `` marker tags to the bottom of the template. - `RouterOutlet` is one of the `ROUTER_DIRECTIVES`. - The router displays each component immediately below the `` as we navigate through the application. - - ### Router Links - We don't really expect users to paste a route URL into the address bar. - We add an anchor tag to the template which, when clicked, triggers navigation to the `HeroesComponent`. - - The revised template looks like this: -+makeExample('toh-5/dart/lib/app_component_2.dart', 'template', 'lib/app_component.dart (template v1)')(format=".") -:marked - Notice the `[routerLink]` binding in the anchor tag. - We bind the `RouterLink` directive (another of the `ROUTER_DIRECTIVES`) to a list - that tells the router where to navigate when the user clicks the link. - - We define a *routing instruction* with a *link parameters list*. - The list only has one element in our little sample, the quoted ***name* of the route** to follow. - Looking back at the route configuration, we confirm that `'Heroes'` is the name of the route to the `HeroesComponent`. -.l-sub-section +block router-config-intro :marked - Learn about the *link parameters list* in the [Routing](../guide/router.html#link-parameters-array) chapter. -:marked - Refresh the browser. We see only the app title. We don't see the heroes list. -.l-sub-section + ### Configure routes and add the router + + The `AppComponent` doesn't have a router yet. We'll use the `@RouteConfig` + annotation to simultaneously: + + - Assign a router to the component + - Configure that router with *routes* + +block routerLink :marked - The browser's address bar shows `/`. - The route path to `HeroesComponent` is `/heroes`, not `/`. - We don't have a route that matches the path `/`, so there is nothing to show. - That's something we'll want to fix. -:marked - We click the "Heroes" navigation link, the browser bar updates to `/heroes`, - and now we see the list of heroes. We are navigating at last! + Notice the `[routerLink]` binding in the anchor tag. + We bind the `RouterLink` directive (another of the `ROUTER_DIRECTIVES`) to a list + that tells the router where to navigate when the user clicks the link. - At this stage, our `AppComponent` looks like this. -+makeExample('toh-5/dart/lib/app_component_2.dart',null, 'lib/app_component.dart (v2)') -:marked - The *AppComponent* is now attached to a router and displaying routed views. - For this reason and to distinguish it from other kinds of components, - we call this type of component a *Router Component*. + We define a *routing instruction* with a *link parameters list*. + The list only has one element in our little sample, the quoted ***name* of the route** to follow. + Looking back at the route configuration, we confirm that `'Heroes'` is the name of the route to the `HeroesComponent`. + .l-sub-section + :marked + Learn about the *link parameters list* + in the [Routing](../guide/router.html#link-parameters-array) chapter. - -:marked - ## Add a *Dashboard* - Routing only makes sense when we have multiple views. We need another view. - - Create a placeholder `DashboardComponent` that gives us something to navigate to and from. -+makeExample('toh-5/dart/lib/dashboard_component_1.dart',null, 'lib/dashboard_component.dart (v1)')(format=".") -:marked - We’ll come back and make it more useful later. - - ### Configure the dashboard route - Go back to `app_component.dart` and teach it to navigate to the dashboard. - - Import the `DashboardComponent` so we can reference it in the dashboard route definition. - - Add the following `'Dashboard'` route definition to the `@RouteConfig` list of definitions. -+makeExample('toh-5/dart/lib/app_component.dart','dashboard-route', 'lib/app_component.dart (Dashboard route)')(format=".") -.l-sub-section +block redirect-vs-use-as-default :marked - **useAsDefault** - - We want the app to show the dashboard when it starts and - we want to see a nice URL in the browser address bar that says `/dashboard`. - Remember that the browser launches with `/` in the address bar. - We don't have a route for that path and we'd rather not create one. - - Fortunately we can add the `useAsDefault: true` property to the *route definition* and the + We don't need a route definition for that. Instead, + we add `useAsDefault: true` to the dashboard *route definition* and the router will display the dashboard when the browser URL doesn't match an existing route. -:marked - Finally, add a dashboard navigation link to the template, just above the *Heroes* link. -+makeExample('toh-5/dart/lib/app_component.dart','template', 'lib/app_component.dart (template)')(format=".") -.l-sub-section +block templateUrl-path-resolution :marked - We nestled the two links within `