diff --git a/.editorconfig b/.editorconfig index bab156b63a..1cf867f786 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,7 +5,6 @@ root = true charset = utf-8 indent_style = space indent_size = 2 -end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true diff --git a/.gitignore b/.gitignore index 679af37907..2666d27c27 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ node_modules _temp bower_components jspm_packages -typings **/packages build pubspec.lock diff --git a/.travis.yml b/.travis.yml index 4be0d614e0..394e81297a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,7 @@ env: - DBUS_SESSION_BUS_ADDRESS=/dev/null - DISPLAY=:99.0 - CHROME_BIN=chromium-browser - # using SHA instead of version to fix build-compile issue - - LATEST_RELEASE=2.1.0 + - LATEST_RELEASE=2.1.1 - TASK_FLAGS="--dgeni-log=warn" matrix: - TASK=lint diff --git a/gulpfile.js b/gulpfile.js index b4ff433065..f95b3df6ca 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -85,7 +85,7 @@ var _apiShredOptionsForDart = { logLevel: _dgeniLogLevel }; -var _excludePatterns = ['**/node_modules/**', '**/typings/**', '**/packages/**']; +var _excludePatterns = ['**/node_modules/**', '**/packages/**']; var _excludeMatchers = _excludePatterns.map(function(excludePattern){ return new Minimatch(excludePattern) @@ -364,11 +364,13 @@ function runProtractorAoT(appDir, outputFile) { // fileName; then shut down the example. All protractor output is appended // to the outputFile. function runE2eDartTests(appDir, outputFile) { - var deployDir = path.resolve(path.join(appDir, 'build/web')); + // Launch http server out of ts directory because all the config files are there. + var httpLaunchDir = path.resolve(appDir, '../ts'); + var deployDir = path.resolve(appDir, 'build/web'); gutil.log('AppDir for Dart e2e: ' + appDir); gutil.log('Deploying from: ' + deployDir); - var appRunSpawnInfo = spawnExt('npm', ['run', 'http-server:e2e', '--', deployDir, '-s'], { cwd: EXAMPLES_PATH }); + var appRunSpawnInfo = spawnExt('npm', ['run', 'http-server:e2e', '--', deployDir, '-s'], { cwd: httpLaunchDir }); if (!appRunSpawnInfo.proc.pid) { gutil.log('http-server failed to launch over ' + deployDir); return false; @@ -461,13 +463,6 @@ gulp.task('add-example-boilerplate', function(done) { fsUtils.addSymlink(realPath, linkPath); }); - realPath = path.join(EXAMPLES_PATH, '/typings'); - var typingsPaths = excludeDartPaths(getTypingsPaths(EXAMPLES_PATH)); - typingsPaths.forEach(function(linkPath) { - gutil.log("symlinking " + linkPath + ' -> ' + realPath) - fsUtils.addSymlink(realPath, linkPath); - }); - return buildStyles(copyExampleBoilerplate, done); }); @@ -530,11 +525,6 @@ gulp.task('remove-example-boilerplate', function() { fsUtils.removeSymlink(linkPath); }); - var typingsPaths = getTypingsPaths(EXAMPLES_PATH); - typingsPaths.forEach(function(linkPath) { - fsUtils.removeSymlink(linkPath); - }); - deleteExampleBoilerPlate(); }); @@ -818,7 +808,7 @@ gulp.task('_harp-compile', function() { gulp.task('_shred-devguide-examples', ['_shred-clean-devguide', '_copy-example-boilerplate'], function() { // Split big shredding task into partials 2016-06-14 - var examplePaths = globby.sync(EXAMPLES_PATH+'/*/', {ignore: ['/node_modules', 'typings/']}); + var examplePaths = globby.sync(EXAMPLES_PATH+'/*/', {ignore: ['/node_modules']}); var promise = Promise.resolve(true); examplePaths.forEach(function (examplePath) { promise = promise.then(() => docShredder.shredSingleExampleDir(_devguideShredOptions, examplePath)); @@ -877,8 +867,6 @@ gulp.task('lint', function() { '!./public/docs/_examples/**/ts-snippets/*.ts', '!./public/docs/_examples/style-guide/ts/**/*.avoid.ts', '!./public/docs/_examples/**/node_modules/**/*', - '!./public/docs/_examples/**/typings/**/*', - '!./public/docs/_examples/**/typings-ng1/**/*', '!./public/docs/_examples/**/build/**/*', // temporary until codelyzer is fixed mgechev/codelyzer#60 '!./public/docs/_examples/animations/ts/app/hero.service.ts' @@ -1140,13 +1128,6 @@ function getNodeModulesPaths(basePath) { return paths; } -function getTypingsPaths(basePath) { - var paths = getExamplePaths(basePath).map(function(examplePath) { - return path.join(examplePath, "/typings"); - }); - return paths; -} - function getExamplePaths(basePath, includeBase) { // includeBase defaults to false return getPaths(basePath, _exampleConfigFilename, includeBase); @@ -1285,7 +1266,7 @@ function devGuideExamplesWatch(shredOptions, postShredAction, focus) { // removed this version because gulp.watch has the same glob issue that dgeni has. // var excludePattern = '!' + path.join(shredOptions.examplesDir, '**/node_modules/**/*.*'); // gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) { - var ignoreThese = [ '**/node_modules/**', '**/_fragments/**', '**/dist/**', '**/typings/**', + var ignoreThese = [ '**/node_modules/**', '**/_fragments/**', '**/dist/**', '**/dart/.pub/**', '**/dart/build/**', '**/dart/packages/**']; ignoreThese = ignoreThese.concat(_exampleBoilerplateFiles.map((file) => `public/docs/_examples/*/*/${file}`)); var files = globby.sync( [includePattern], { ignore: ignoreThese }); @@ -1385,14 +1366,14 @@ function buildApiDocsForDart() { dabInfo.ngDartDocPath = path.join(ngPathFor('dart'), relDartDocApiDir); // 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$/); + dabInfo.excludeLibRegExp = new RegExp(/^(?!angular2)|testing|_|codegen|^angular2$/); try { checkAngularProjectPath(ngPathFor('dart')); var destPath = dabInfo.ngIoDartApiDocPath; var sourceDirs = fs.readdirSync(dabInfo.ngDartDocPath) - .filter((name) => !name.match(/^index/)) - .map((name) => path.join(dabInfo.ngDartDocPath, name)); + .filter(name => !name.match(/^index|^(?!angular2)|testing|codegen/)) + .map(name => path.join(dabInfo.ngDartDocPath, name)); log.info(`Building Dart API pages for ${sourceDirs.length} libraries`); return copyFiles(sourceDirs, [destPath]).then(() => { @@ -1402,7 +1383,6 @@ function buildApiDocsForDart() { const tmpDocsPath = path.resolve(path.join(process.env.HOME, 'tmp/docs.json')); if (argv.dumpDocsJson) fs.writeFileSync(tmpDocsPath, JSON.stringify(apiEntries, null, 2)); dab.createApiDataAndJadeFiles(apiEntries); - }).catch((err) => { console.error(err); }); diff --git a/harp.json b/harp.json index a4a2f0c878..648e23e405 100644 --- a/harp.json +++ b/harp.json @@ -7,7 +7,6 @@ "jsLatest": "2.0.0-beta.02", "dartLatest": "2.0.0-beta.02", "jade2ng": false, - "bios": { "misko": { "name": "Miško Hevery", diff --git a/public/_includes/_hero-home.jade b/public/_includes/_hero-home.jade index be6d6c61aa..6261d7506b 100644 --- a/public/_includes/_hero-home.jade +++ b/public/_includes/_hero-home.jade @@ -7,6 +7,6 @@ header(class="background-sky l-relative") announcement-bar .announcement-bar-slide.clearfix - img(src="/resources/images/logos/anglebrackets/anglebrackets.png" width="64") - p 参加10.25~10.28拉斯维加斯召开的Anglebrackets大会! - a(href="https://anglebrackets.org/#!/" target="_blank" class="button md-button") 立即注册 + img(src="/resources/images/logos/anglebrackets/devintersection.png" width="64") + p 参加11月14-16号的DEVintersection Amsterdam! + a(href="https://www.devintersectioneurope.com/#!/" target="_blank" class="button md-button") Register now diff --git a/public/_layout.jade b/public/_layout.jade index 358f4c1ccd..6f01183b22 100644 --- a/public/_layout.jade +++ b/public/_layout.jade @@ -1,23 +1,33 @@ -doctype html public -html(lang="en" ng-app="angularIOApp" itemscope itemtype="http://schema.org/Framework") - head - != partial("/_includes/_head-include") +if jade2ng + if hero == 'home' + != partial("/_includes/_hero-home") + else + != partial("/_includes/_hero") + != partial("../_includes/_banner") + - var format = autoformat ? 'docs-content' : '' + article(class="l-content #{format}") + != yield +else + doctype html public + html(lang="en" ng-app="angularIOApp" itemscope itemtype="http://schema.org/Framework") + head + != partial("/_includes/_head-include") - body.ng-cloak.l-offset-nav(ng-controller="AppCtrl as appCtrl") - != partial("/_includes/_main-nav") + body.ng-cloak.l-offset-nav(ng-controller="AppCtrl as appCtrl") + != partial("/_includes/_main-nav") - - if hero == 'home' - != partial("/_includes/_hero-home") - else - != partial("/_includes/_hero") + + if hero == 'home' + != partial("/_includes/_hero-home") + else + != partial("/_includes/_hero") - - var format = autoformat ? 'docs-content' : '' + - var format = autoformat ? 'docs-content' : '' - article(class="l-content #{format}") - != yield + article(class="l-content #{format}") + != yield - != partial("/_includes/_footer") - != partial("/_includes/_scripts-include") - != partial("/_includes/_scripts-minimum") \ No newline at end of file + != partial("/_includes/_footer") + != partial("/_includes/_scripts-include") + != partial("/_includes/_scripts-minimum") diff --git a/public/docs/_examples/.gitignore b/public/docs/_examples/.gitignore index 3e900ec40a..b6733dc6ea 100644 --- a/public/docs/_examples/.gitignore +++ b/public/docs/_examples/.gitignore @@ -7,7 +7,6 @@ package.json systemjs.config.js tsconfig.json tslint.json -typings.json wallaby.js _test-output diff --git a/public/docs/_examples/_boilerplate/package.json b/public/docs/_examples/_boilerplate/package.json index 758ff6f182..3f255fcbd6 100644 --- a/public/docs/_examples/_boilerplate/package.json +++ b/public/docs/_examples/_boilerplate/package.json @@ -10,7 +10,6 @@ "http-server:cli": "http-server dist/", "lite": "lite-server", "lite:aot": "lite-server -c aot/bs-config.json", - "postinstall": "typings install", "test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"", "tsc": "tsc", "tsc:w": "tsc -w", diff --git a/public/docs/_examples/_boilerplate/systemjs.config.js b/public/docs/_examples/_boilerplate/systemjs.config.js index 0ea776d8f3..457f040fc0 100644 --- a/public/docs/_examples/_boilerplate/systemjs.config.js +++ b/public/docs/_examples/_boilerplate/systemjs.config.js @@ -26,7 +26,7 @@ // other libraries 'rxjs': 'npm:rxjs', - 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api', + 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js' }, // packages tells the System loader how to load when no filename and/or no extension packages: { @@ -36,10 +36,6 @@ }, rxjs: { defaultExtension: 'js' - }, - 'angular-in-memory-web-api': { - main: './index.js', - defaultExtension: 'js' } } }); diff --git a/public/docs/_examples/_boilerplate/systemjs.config.plunker.build.js b/public/docs/_examples/_boilerplate/systemjs.config.plunker.build.js index 41015e2e43..e89a192c77 100644 --- a/public/docs/_examples/_boilerplate/systemjs.config.plunker.build.js +++ b/public/docs/_examples/_boilerplate/systemjs.config.plunker.build.js @@ -51,9 +51,9 @@ // other libraries 'rxjs': 'npm:rxjs', - 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api', + 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js', 'ts': 'npm:plugin-typescript@4.0.10/lib/plugin.js', - 'typescript': 'npm:typescript@2.0.2/lib/typescript.js', + 'typescript': 'npm:typescript@2.0.3/lib/typescript.js', }, // packages tells the System loader how to load when no filename and/or no extension @@ -64,10 +64,6 @@ }, rxjs: { defaultExtension: 'js' - }, - 'angular-in-memory-web-api': { - main: './index.js', - defaultExtension: 'js' } } }); diff --git a/public/docs/_examples/_boilerplate/systemjs.config.plunker.js b/public/docs/_examples/_boilerplate/systemjs.config.plunker.js index c5314b3170..4504d87d72 100644 --- a/public/docs/_examples/_boilerplate/systemjs.config.plunker.js +++ b/public/docs/_examples/_boilerplate/systemjs.config.plunker.js @@ -38,9 +38,9 @@ // other libraries 'rxjs': 'npm:rxjs', - 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api', + 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js', 'ts': 'npm:plugin-typescript@4.0.10/lib/plugin.js', - 'typescript': 'npm:typescript@2.0.2/lib/typescript.js', + 'typescript': 'npm:typescript@2.0.3/lib/typescript.js', }, // packages tells the System loader how to load when no filename and/or no extension @@ -51,10 +51,6 @@ }, rxjs: { defaultExtension: 'js' - }, - 'angular-in-memory-web-api': { - main: './index.js', - defaultExtension: 'js' } } }); diff --git a/public/docs/_examples/_boilerplate/tsconfig.json b/public/docs/_examples/_boilerplate/tsconfig.json index 48dda0636f..d90e457b10 100644 --- a/public/docs/_examples/_boilerplate/tsconfig.json +++ b/public/docs/_examples/_boilerplate/tsconfig.json @@ -9,8 +9,11 @@ "removeComments": false, "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true, - "types": [] + "typeRoots": [ + "../../node_modules/@types/" + ] }, + "compileOnSave": true, "exclude": [ "node_modules/*", "**/*-aot.ts" diff --git a/public/docs/_examples/architecture/dart/pubspec.yaml b/public/docs/_examples/architecture/dart/pubspec.yaml index 3f869b06ca..4b7f63f5f0 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 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 7b14c2b11c..d432cac246 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/cb-aot-compiler/ts/tsconfig-aot.json b/public/docs/_examples/cb-aot-compiler/ts/tsconfig-aot.json index fd8b0617cc..2a8ebdf309 100644 --- a/public/docs/_examples/cb-aot-compiler/ts/tsconfig-aot.json +++ b/public/docs/_examples/cb-aot-compiler/ts/tsconfig-aot.json @@ -8,14 +8,12 @@ "experimentalDecorators": true, "removeComments": false, "noImplicitAny": true, - "suppressImplicitAnyIndexErrors": true, - "types": [] + "suppressImplicitAnyIndexErrors": true }, "files": [ "app/app.module.ts", - "app/main.ts", - "./typings/index.d.ts" + "app/main.ts" ], "angularCompilerOptions": { diff --git a/public/docs/_examples/cb-form-validation/ts/index.html b/public/docs/_examples/cb-form-validation/ts/index.html index 6aea5beaa4..8fc614fe0f 100644 --- a/public/docs/_examples/cb-form-validation/ts/index.html +++ b/public/docs/_examples/cb-form-validation/ts/index.html @@ -5,7 +5,7 @@ - + diff --git a/public/docs/_examples/cb-visual-studio-2015/ts/tsconfig.json b/public/docs/_examples/cb-visual-studio-2015/ts/tsconfig.json index 1ac74de56e..2624488890 100644 --- a/public/docs/_examples/cb-visual-studio-2015/ts/tsconfig.json +++ b/public/docs/_examples/cb-visual-studio-2015/ts/tsconfig.json @@ -8,7 +8,10 @@ "experimentalDecorators": true, "removeComments": false, "noImplicitAny": true, - "suppressImplicitAnyIndexErrors": true + "suppressImplicitAnyIndexErrors": true, + "typeRoots": [ + "node_modules/@types" + ] }, "compileOnSave": true } diff --git a/public/docs/_examples/cli-quickstart/e2e-spec.ts.disabled b/public/docs/_examples/cli-quickstart/e2e-spec.ts.temporarily-removed similarity index 100% rename from public/docs/_examples/cli-quickstart/e2e-spec.ts.disabled rename to public/docs/_examples/cli-quickstart/e2e-spec.ts.temporarily-removed diff --git a/public/docs/_examples/cli-quickstart/ts/.gitignore b/public/docs/_examples/cli-quickstart/ts/.gitignore index 5df0fe5dc6..129ad319d9 100644 --- a/public/docs/_examples/cli-quickstart/ts/.gitignore +++ b/public/docs/_examples/cli-quickstart/ts/.gitignore @@ -18,7 +18,6 @@ /libpeerconnection.log npm-debug.log testem.log -/typings # e2e /e2e/*.js diff --git a/public/docs/_examples/cli-quickstart/ts/example-config.json b/public/docs/_examples/cli-quickstart/ts/example-config.json.temporarily-removed similarity index 100% rename from public/docs/_examples/cli-quickstart/ts/example-config.json rename to public/docs/_examples/cli-quickstart/ts/example-config.json.temporarily-removed diff --git a/public/docs/_examples/cli-quickstart/ts/src/typings.d.ts b/public/docs/_examples/cli-quickstart/ts/src/typings.d.ts index eebc2728b8..e69de29bb2 100644 --- a/public/docs/_examples/cli-quickstart/ts/src/typings.d.ts +++ b/public/docs/_examples/cli-quickstart/ts/src/typings.d.ts @@ -1 +0,0 @@ -/// diff --git a/public/docs/_examples/component-styles/dart/pubspec.yaml b/public/docs/_examples/component-styles/dart/pubspec.yaml index b937fd8f72..5b129ec698 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 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 366b014304..14030bc995 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 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 ad1736d951..8fe96ff267 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 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 4f13a2ca4b..62c3e32f16 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/forms/js/index.html b/public/docs/_examples/forms/js/index.html index e67b53ac26..a7052b79db 100644 --- a/public/docs/_examples/forms/js/index.html +++ b/public/docs/_examples/forms/js/index.html @@ -7,7 +7,7 @@ - + diff --git a/public/docs/_examples/forms/ts/index.html b/public/docs/_examples/forms/ts/index.html index 7d6e7cda5d..50f8747546 100644 --- a/public/docs/_examples/forms/ts/index.html +++ b/public/docs/_examples/forms/ts/index.html @@ -8,7 +8,7 @@ + href="https://unpkg.com/bootstrap@3.3.7/dist/css/bootstrap.min.css"> diff --git a/public/docs/_examples/hierarchical-dependency-injection/dart/pubspec.yaml b/public/docs/_examples/hierarchical-dependency-injection/dart/pubspec.yaml index d7a003cf3c..da716d37eb 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/homepage-hello-world/ts/index.1.html b/public/docs/_examples/homepage-hello-world/ts/index.1.html index da3cd256c2..7ea19e1842 100644 --- a/public/docs/_examples/homepage-hello-world/ts/index.1.html +++ b/public/docs/_examples/homepage-hello-world/ts/index.1.html @@ -13,7 +13,7 @@ - + diff --git a/public/docs/_examples/homepage-tabs/ts/index.1.html b/public/docs/_examples/homepage-tabs/ts/index.1.html index bd3342ee3f..5ca7d182a6 100644 --- a/public/docs/_examples/homepage-tabs/ts/index.1.html +++ b/public/docs/_examples/homepage-tabs/ts/index.1.html @@ -14,7 +14,7 @@ - + diff --git a/public/docs/_examples/homepage-tabs/ts/index.html b/public/docs/_examples/homepage-tabs/ts/index.html index 66ce8f3ecc..d047702a13 100644 --- a/public/docs/_examples/homepage-tabs/ts/index.html +++ b/public/docs/_examples/homepage-tabs/ts/index.html @@ -5,7 +5,7 @@ Angular Tabs - + diff --git a/public/docs/_examples/homepage-todo/ts/index.html b/public/docs/_examples/homepage-todo/ts/index.html index 8839065224..6bed22fce1 100644 --- a/public/docs/_examples/homepage-todo/ts/index.html +++ b/public/docs/_examples/homepage-todo/ts/index.html @@ -5,7 +5,7 @@ Angular Todos - + diff --git a/public/docs/_examples/lifecycle-hooks/dart/pubspec.yaml b/public/docs/_examples/lifecycle-hooks/dart/pubspec.yaml index 25c5106c9b..11fe5c36db 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/package.json b/public/docs/_examples/package.json index 871fba0218..a46ac1b718 100644 --- a/public/docs/_examples/package.json +++ b/public/docs/_examples/package.json @@ -3,8 +3,6 @@ "version": "1.0.0", "description": "Master package.json, the superset of all dependencies for all of the _example package.json files. See _boilerplate/package.json for example npm scripts.", "scripts": { - "postinstall": "typings install", - "typings": "typings", "protractor": "protractor", "webdriver:update": "webdriver-manager update" }, @@ -17,22 +15,20 @@ } ], "dependencies": { - "@angular/common": "~2.1.0", - "@angular/compiler": "~2.1.0", - "@angular/compiler-cli": "~2.1.0", - "@angular/core": "~2.1.0", - "@angular/forms": "~2.1.0", - "@angular/http": "~2.1.0", - "@angular/platform-browser": "~2.1.0", - "@angular/platform-browser-dynamic": "~2.1.0", - "@angular/platform-server": "~2.1.0", - "@angular/router": "~3.1.0", - "@angular/upgrade": "~2.1.0", + "@angular/common": "~2.1.1", + "@angular/compiler": "~2.1.1", + "@angular/compiler-cli": "~2.1.1", + "@angular/core": "~2.1.1", + "@angular/forms": "~2.1.1", + "@angular/http": "~2.1.1", + "@angular/platform-browser": "~2.1.1", + "@angular/platform-browser-dynamic": "~2.1.1", + "@angular/platform-server": "~2.1.1", + "@angular/router": "~3.1.1", + "@angular/upgrade": "~2.1.1", - "angular-in-memory-web-api": "~0.1.5", - "bootstrap": "^3.3.7", + "angular-in-memory-web-api": "~0.1.13", "core-js": "^2.4.1", - "protractor": "^4.0.9", "reflect-metadata": "^0.1.8", "rollup": "^0.36.0", "rollup-plugin-node-resolve": "^2.0.0", @@ -42,8 +38,16 @@ "zone.js": "^0.6.25" }, "devDependencies": { - "@types/angular": "^1.5.15", - "@types/jasmine": "^2.2.34", + "@types/angular": "^1.5.16", + "@types/angular-animate": "^1.5.5", + "@types/angular-cookies": "^1.4.2", + "@types/angular-mocks": "^1.5.5", + "@types/angular-resource": "^1.5.6", + "@types/angular-route": "^1.3.2", + "@types/angular-sanitize": "^1.3.3", + "@types/core-js": "^0.9.34", + "@types/jasmine": "~2.5.36", + "@types/node": "^6.0.45", "@types/selenium-webdriver": "^2.53.32", "angular2-template-loader": "^0.4.0", "awesome-typescript-loader": "^2.2.4", @@ -55,8 +59,8 @@ "html-loader": "^0.4.3", "html-webpack-plugin": "^2.16.1", "http-server": "^0.9.0", - "jasmine": "^2.5.2", - "jasmine-core": "^2.5.2", + "jasmine": "~2.4.1", + "jasmine-core": "~2.4.1", "karma": "^1.3.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", @@ -70,17 +74,16 @@ "lodash": "^4.16.2", "null-loader": "^0.1.1", "phantomjs-prebuilt": "^2.1.7", - "protractor": "^4.0.9", + "protractor": "4.0.9", "raw-loader": "^0.5.1", "rimraf": "^2.5.4", "rollup-plugin-commonjs": "^4.1.0", "source-map-explorer": "^1.3.2", "style-loader": "^0.13.1", - "ts-loader": "^0.8.2", "ts-node": "^1.3.0", "tslint": "^3.15.1", "typescript": "^2.0.3", - "typings": "^1.4.0", + "webdriver-manager": "10.2.5", "webpack": "^1.13.0", "webpack-dev-server": "^1.14.1", "webpack-merge": "^0.14.0" diff --git a/public/docs/_examples/pipes/dart/pubspec.yaml b/public/docs/_examples/pipes/dart/pubspec.yaml index 6ac1328d66..6a69c51627 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/quickstart/dart/pubspec.yaml b/public/docs/_examples/quickstart/dart/pubspec.yaml index 39b7e10d28..d497066817 100644 --- a/public/docs/_examples/quickstart/dart/pubspec.yaml +++ b/public/docs/_examples/quickstart/dart/pubspec.yaml @@ -5,7 +5,8 @@ version: 0.0.1 environment: sdk: '>=1.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 +dev_dependencies: browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/quickstart/js/package.1.json b/public/docs/_examples/quickstart/js/package.1.json index 5c88b0bb5e..212ffc8735 100644 --- a/public/docs/_examples/quickstart/js/package.1.json +++ b/public/docs/_examples/quickstart/js/package.1.json @@ -12,18 +12,17 @@ } ], "dependencies": { - "@angular/common": "~2.1.0", - "@angular/compiler": "~2.1.0", - "@angular/core": "~2.1.0", - "@angular/forms": "~2.1.0", - "@angular/http": "~2.1.0", - "@angular/platform-browser": "~2.1.0", - "@angular/platform-browser-dynamic": "~2.1.0", - "@angular/router": "~3.1.0", - "@angular/upgrade": "~2.1.0", + "@angular/common": "~2.1.1", + "@angular/compiler": "~2.1.1", + "@angular/core": "~2.1.1", + "@angular/forms": "~2.1.1", + "@angular/http": "~2.1.1", + "@angular/platform-browser": "~2.1.1", + "@angular/platform-browser-dynamic": "~2.1.1", + "@angular/router": "~3.1.1", + "@angular/upgrade": "~2.1.1", "angular-in-memory-web-api": "~0.1.5", - "bootstrap": "^3.3.7", "core-js": "^2.4.1", "reflect-metadata": "^0.1.8", "rxjs": "5.0.0-beta.12", diff --git a/public/docs/_examples/quickstart/ts/package.1.json b/public/docs/_examples/quickstart/ts/package.1.json index 29eb574dd9..0eddc20502 100644 --- a/public/docs/_examples/quickstart/ts/package.1.json +++ b/public/docs/_examples/quickstart/ts/package.1.json @@ -4,10 +4,8 @@ "scripts": { "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ", "lite": "lite-server", - "postinstall": "typings install", "tsc": "tsc", - "tsc:w": "tsc -w", - "typings": "typings" + "tsc:w": "tsc -w" }, "licenses": [ { @@ -16,18 +14,17 @@ } ], "dependencies": { - "@angular/common": "~2.1.0", - "@angular/compiler": "~2.1.0", - "@angular/core": "~2.1.0", - "@angular/forms": "~2.1.0", - "@angular/http": "~2.1.0", - "@angular/platform-browser": "~2.1.0", - "@angular/platform-browser-dynamic": "~2.1.0", - "@angular/router": "~3.1.0", - "@angular/upgrade": "~2.1.0", + "@angular/common": "~2.1.1", + "@angular/compiler": "~2.1.1", + "@angular/core": "~2.1.1", + "@angular/forms": "~2.1.1", + "@angular/http": "~2.1.1", + "@angular/platform-browser": "~2.1.1", + "@angular/platform-browser-dynamic": "~2.1.1", + "@angular/router": "~3.1.1", + "@angular/upgrade": "~2.1.1", - "angular-in-memory-web-api": "~0.1.5", - "bootstrap": "^3.3.7", + "angular-in-memory-web-api": "~0.1.13", "core-js": "^2.4.1", "reflect-metadata": "^0.1.8", "rxjs": "5.0.0-beta.12", @@ -35,9 +32,10 @@ "zone.js": "^0.6.25" }, "devDependencies": { + "@types/core-js": "^0.9.34", + "@types/node": "^6.0.45", "concurrently": "^3.0.0", "lite-server": "^2.2.2", - "typescript": "^2.0.3", - "typings":"^1.4.0" + "typescript": "^2.0.3" } } diff --git a/public/docs/_examples/quickstart/ts/systemjs.config.1.js b/public/docs/_examples/quickstart/ts/systemjs.config.1.js index afe873791d..2b39cec3f7 100644 --- a/public/docs/_examples/quickstart/ts/systemjs.config.1.js +++ b/public/docs/_examples/quickstart/ts/systemjs.config.1.js @@ -23,10 +23,11 @@ '@angular/http': 'npm:@angular/http/bundles/http.umd.js', '@angular/router': 'npm:@angular/router/bundles/router.umd.js', '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', + '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js', // other libraries 'rxjs': 'npm:rxjs', - 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js', + 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js' }, // packages tells the System loader how to load when no filename and/or no extension packages: { diff --git a/public/docs/_examples/quickstart/ts/typings.1.json b/public/docs/_examples/quickstart/ts/typings.1.json deleted file mode 100644 index 7da31ca0af..0000000000 --- a/public/docs/_examples/quickstart/ts/typings.1.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160725163759", - "jasmine": "registry:dt/jasmine#2.2.0+20160621224255", - "node": "registry:dt/node#6.0.0+20160909174046" - } -} diff --git a/public/docs/_examples/router/e2e-spec.ts b/public/docs/_examples/router/e2e-spec.ts index a3d6d9b926..cb5d05a5a7 100644 --- a/public/docs/_examples/router/e2e-spec.ts +++ b/public/docs/_examples/router/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by, ElementFinder } from 'protractor'; @@ -27,7 +27,10 @@ describe('Router', function () { heroDetailTitle: element(by.css('my-app > ng-component > div > h3')), adminHref: hrefEles.get(2), - loginHref: hrefEles.get(3) + adminPreloadList: element.all(by.css('my-app > ng-component > ng-component > ul > li')), + loginHref: hrefEles.get(3), + loginButton: element.all(by.css('my-app > ng-component > p > button')), + }; } @@ -105,6 +108,16 @@ describe('Router', function () { }); }); + it('should be able to see the preloaded modules', function () { + let page = getPageStruct(); + page.loginHref.click().then(function() { + return page.loginButton.click(); + }).then(function() { + expect(page.adminPreloadList.count()).toBe(1, 'should be 1 preloaded module'); + expect(page.adminPreloadList.first().getText()).toBe('crisis-center', 'first preload should be crisis center'); + }); + }); + function crisisCenterEdit(index: number, shouldSave: boolean) { let page = getPageStruct(); let crisisEle: ElementFinder; diff --git a/public/docs/_examples/router/ts/app/admin/admin-dashboard.component.2.ts b/public/docs/_examples/router/ts/app/admin/admin-dashboard.component.2.ts new file mode 100644 index 0000000000..8c8e481643 --- /dev/null +++ b/public/docs/_examples/router/ts/app/admin/admin-dashboard.component.2.ts @@ -0,0 +1,33 @@ +// #docregion +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/map'; + +@Component({ + template: ` +

Dashboard

+ +

Session ID: {{ sessionId | async }}

+ +

Token: {{ token | async }}

+ ` +}) +export class AdminDashboardComponent implements OnInit { + sessionId: Observable; + token: Observable; + + constructor(private route: ActivatedRoute) {} + + ngOnInit() { + // Capture the session ID if available + this.sessionId = this.route + .queryParams + .map(params => params['session_id'] || 'None'); + + // Capture the fragment if available + this.token = this.route + .fragment + .map(fragment => fragment || 'None'); + } +} diff --git a/public/docs/_examples/router/ts/app/admin/admin-dashboard.component.ts b/public/docs/_examples/router/ts/app/admin/admin-dashboard.component.ts index 8c8e481643..02574829c0 100644 --- a/public/docs/_examples/router/ts/app/admin/admin-dashboard.component.ts +++ b/public/docs/_examples/router/ts/app/admin/admin-dashboard.component.ts @@ -1,7 +1,9 @@ // #docregion -import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { Observable } from 'rxjs/Observable'; +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { Observable } from 'rxjs/Observable'; +import { PreloadSelectedModules } from '../selective-preload-strategy'; + import 'rxjs/add/operator/map'; @Component({ @@ -11,13 +13,24 @@ import 'rxjs/add/operator/map';

Session ID: {{ sessionId | async }}

Token: {{ token | async }}

+ + Preloaded Modules +
    +
  • {{ module }}
  • +
` }) export class AdminDashboardComponent implements OnInit { sessionId: Observable; token: Observable; + modules: string[]; - constructor(private route: ActivatedRoute) {} + constructor( + private route: ActivatedRoute, + private preloadStrategy: PreloadSelectedModules + ) { + this.modules = preloadStrategy.preloadedModules; + } ngOnInit() { // Capture the session ID if available diff --git a/public/docs/_examples/router/ts/app/app-routing.module.5.ts b/public/docs/_examples/router/ts/app/app-routing.module.5.ts new file mode 100644 index 0000000000..6e35f64f73 --- /dev/null +++ b/public/docs/_examples/router/ts/app/app-routing.module.5.ts @@ -0,0 +1,33 @@ +// #docplaster +// #docregion +import { NgModule } from '@angular/core'; +// #docregion import-router +import { RouterModule } from '@angular/router'; +// #enddocregion import-router + +import { CanDeactivateGuard } from './can-deactivate-guard.service'; +// #docregion can-load-guard +import { AuthGuard } from './auth-guard.service'; +// #enddocregion can-load-guard + +// #docregion lazy-load-admin, can-load-guard +@NgModule({ + imports: [ + RouterModule.forRoot([ + { + path: 'admin', + loadChildren: 'app/admin/admin.module#AdminModule', + // #enddocregion lazy-load-admin + canLoad: [AuthGuard] + // #docregion lazy-load-admin + } + ]) + ], + exports: [ + RouterModule + ], + providers: [ + CanDeactivateGuard + ] +}) +export class AppRoutingModule {} diff --git a/public/docs/_examples/router/ts/app/app-routing.module.6.ts b/public/docs/_examples/router/ts/app/app-routing.module.6.ts new file mode 100644 index 0000000000..68bcc30413 --- /dev/null +++ b/public/docs/_examples/router/ts/app/app-routing.module.6.ts @@ -0,0 +1,44 @@ +// #docplaster +// #docregion, preload-v1 +import { NgModule } from '@angular/core'; +import { + RouterModule, +// #enddocregion preload-v1 + PreloadAllModules +// #docregion preload-v1 +} from '@angular/router'; + +import { CanDeactivateGuard } from './can-deactivate-guard.service'; +import { AuthGuard } from './auth-guard.service'; + +@NgModule({ + imports: [ + RouterModule.forRoot([ + { + path: 'admin', + loadChildren: 'app/admin/admin.module#AdminModule', + canLoad: [AuthGuard] + }, + { + path: '', + redirectTo: '/heroes', + pathMatch: 'full' + }, + { + path: 'crisis-center', + loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule' + }, + ], + // #enddocregion preload-v1 + { preloadingStrategy: PreloadAllModules } + // #docregion preload-v1 + ) + ], + exports: [ + RouterModule + ], + providers: [ + CanDeactivateGuard + ] +}) +export class AppRoutingModule {} diff --git a/public/docs/_examples/router/ts/app/app-routing.module.ts b/public/docs/_examples/router/ts/app/app-routing.module.ts index 6e35f64f73..8fa63edb1c 100644 --- a/public/docs/_examples/router/ts/app/app-routing.module.ts +++ b/public/docs/_examples/router/ts/app/app-routing.module.ts @@ -1,33 +1,43 @@ // #docplaster -// #docregion +// #docregion, preload-v1 import { NgModule } from '@angular/core'; -// #docregion import-router import { RouterModule } from '@angular/router'; -// #enddocregion import-router import { CanDeactivateGuard } from './can-deactivate-guard.service'; -// #docregion can-load-guard import { AuthGuard } from './auth-guard.service'; -// #enddocregion can-load-guard +import { PreloadSelectedModules } from './selective-preload-strategy'; -// #docregion lazy-load-admin, can-load-guard @NgModule({ imports: [ RouterModule.forRoot([ { path: 'admin', loadChildren: 'app/admin/admin.module#AdminModule', - // #enddocregion lazy-load-admin canLoad: [AuthGuard] - // #docregion lazy-load-admin + }, + { + path: '', + redirectTo: '/heroes', + pathMatch: 'full' + }, + // #docregion preload-v2 + { + path: 'crisis-center', + loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule', + data: { + preload: true + } } - ]) + // #enddocregion preload-v2 + ], + { preloadingStrategy: PreloadSelectedModules }) ], exports: [ RouterModule ], providers: [ - CanDeactivateGuard + CanDeactivateGuard, + PreloadSelectedModules ] }) export class AppRoutingModule {} diff --git a/public/docs/_examples/router/ts/app/app.module.7.ts b/public/docs/_examples/router/ts/app/app.module.7.ts index 03f13cc432..8313e3aacf 100644 --- a/public/docs/_examples/router/ts/app/app.module.7.ts +++ b/public/docs/_examples/router/ts/app/app.module.7.ts @@ -9,6 +9,8 @@ import { AppRoutingModule } from './app-routing.module'; import { HeroesModule } from './heroes/heroes.module'; import { CrisisCenterModule } from './crisis-center/crisis-center.module'; import { LoginRoutingModule } from './login-routing.module'; +import { LoginComponent } from './login.component'; + import { DialogService } from './dialog.service'; @NgModule({ @@ -21,7 +23,8 @@ import { DialogService } from './dialog.service'; AppRoutingModule ], declarations: [ - AppComponent + AppComponent, + LoginComponent ], providers: [ DialogService diff --git a/public/docs/_examples/router/ts/app/app.module.ts b/public/docs/_examples/router/ts/app/app.module.ts index e9b4726c74..e557abfb30 100644 --- a/public/docs/_examples/router/ts/app/app.module.ts +++ b/public/docs/_examples/router/ts/app/app.module.ts @@ -5,11 +5,9 @@ import { FormsModule } from '@angular/forms'; import { AppComponent } from './app.component'; import { AppRoutingModule } from './app-routing.module'; -import { LoginRoutingModule } from './login-routing.module'; import { HeroesModule } from './heroes/heroes.module'; -import { CrisisCenterModule } from './crisis-center/crisis-center.module'; - +import { LoginRoutingModule } from './login-routing.module'; import { LoginComponent } from './login.component'; import { DialogService } from './dialog.service'; @@ -19,7 +17,6 @@ import { DialogService } from './dialog.service'; BrowserModule, FormsModule, HeroesModule, - CrisisCenterModule, LoginRoutingModule, AppRoutingModule ], diff --git a/public/docs/_examples/router/ts/app/crisis-center/crisis-center-routing.module.4.ts b/public/docs/_examples/router/ts/app/crisis-center/crisis-center-routing.module.4.ts new file mode 100644 index 0000000000..17843ace3e --- /dev/null +++ b/public/docs/_examples/router/ts/app/crisis-center/crisis-center-routing.module.4.ts @@ -0,0 +1,60 @@ +// #docplaster +// #docregion +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { CrisisCenterHomeComponent } from './crisis-center-home.component'; +import { CrisisListComponent } from './crisis-list.component'; +import { CrisisCenterComponent } from './crisis-center.component'; +import { CrisisDetailComponent } from './crisis-detail.component'; + +import { CanDeactivateGuard } from '../can-deactivate-guard.service'; + +// #docregion crisis-detail-resolve +import { CrisisDetailResolve } from './crisis-detail-resolve.service'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + // #docregion redirect + { + path: '', + redirectTo: '/crisis-center', + pathMatch: 'full' + }, + // #enddocregion redirect + { + path: 'crisis-center', + component: CrisisCenterComponent, + children: [ + { + path: '', + component: CrisisListComponent, + children: [ + { + path: ':id', + component: CrisisDetailComponent, + canDeactivate: [CanDeactivateGuard], + resolve: { + crisis: CrisisDetailResolve + } + }, + { + path: '', + component: CrisisCenterHomeComponent + } + ] + } + ] + } + ]) + ], + exports: [ + RouterModule + ], + providers: [ + CrisisDetailResolve + ] +}) +export class CrisisCenterRoutingModule { } +// #enddocregion diff --git a/public/docs/_examples/router/ts/app/crisis-center/crisis-center-routing.module.ts b/public/docs/_examples/router/ts/app/crisis-center/crisis-center-routing.module.ts index 17843ace3e..e1d2ae1207 100644 --- a/public/docs/_examples/router/ts/app/crisis-center/crisis-center-routing.module.ts +++ b/public/docs/_examples/router/ts/app/crisis-center/crisis-center-routing.module.ts @@ -16,15 +16,8 @@ import { CrisisDetailResolve } from './crisis-detail-resolve.service'; @NgModule({ imports: [ RouterModule.forChild([ - // #docregion redirect { path: '', - redirectTo: '/crisis-center', - pathMatch: 'full' - }, - // #enddocregion redirect - { - path: 'crisis-center', component: CrisisCenterComponent, children: [ { diff --git a/public/docs/_examples/router/ts/app/crisis-center/crisis-detail.component.1.ts b/public/docs/_examples/router/ts/app/crisis-center/crisis-detail.component.1.ts index c23c45ab58..2a52513b6f 100644 --- a/public/docs/_examples/router/ts/app/crisis-center/crisis-detail.component.1.ts +++ b/public/docs/_examples/router/ts/app/crisis-center/crisis-detail.component.1.ts @@ -35,14 +35,14 @@ import { DialogService } from '../dialog.service'; transform: 'translateX(0)' }) ), - transition('void => *', [ + transition(':enter', [ style({ opacity: 0, transform: 'translateX(-100%)' }), animate('0.2s ease-in') ]), - transition('* => void', [ + transition(':leave', [ animate('0.5s ease-out', style({ opacity: 0, transform: 'translateY(100%)' diff --git a/public/docs/_examples/router/ts/app/crisis-center/crisis-detail.component.ts b/public/docs/_examples/router/ts/app/crisis-center/crisis-detail.component.ts index 17ae9ff195..cda3b7dc6a 100644 --- a/public/docs/_examples/router/ts/app/crisis-center/crisis-detail.component.ts +++ b/public/docs/_examples/router/ts/app/crisis-center/crisis-detail.component.ts @@ -34,14 +34,14 @@ import { DialogService } from '../dialog.service'; transform: 'translateX(0)' }) ), - transition('void => *', [ + transition(':enter', [ style({ opacity: 0, transform: 'translateX(-100%)' }), animate('0.2s ease-in') ]), - transition('* => void', [ + transition(':leave', [ animate('0.5s ease-out', style({ opacity: 0, transform: 'translateY(100%)' diff --git a/public/docs/_examples/router/ts/app/heroes/hero-detail.component.ts b/public/docs/_examples/router/ts/app/heroes/hero-detail.component.ts index a263fe65f0..42adbe2d98 100644 --- a/public/docs/_examples/router/ts/app/heroes/hero-detail.component.ts +++ b/public/docs/_examples/router/ts/app/heroes/hero-detail.component.ts @@ -34,14 +34,14 @@ import { Hero, HeroService } from './hero.service'; transform: 'translateX(0)' }) ), - transition('void => *', [ + transition(':enter', [ style({ opacity: 0, transform: 'translateX(-100%)' }), animate('0.2s ease-in') ]), - transition('* => void', [ + transition(':leave', [ animate('0.5s ease-out', style({ opacity: 0, transform: 'translateY(100%)' diff --git a/public/docs/_examples/router/ts/app/selective-preload-strategy.ts b/public/docs/_examples/router/ts/app/selective-preload-strategy.ts new file mode 100644 index 0000000000..ebbd40d294 --- /dev/null +++ b/public/docs/_examples/router/ts/app/selective-preload-strategy.ts @@ -0,0 +1,24 @@ +// #docregion +import 'rxjs/add/observable/of'; +import { Injectable } from '@angular/core'; +import { PreloadingStrategy, Route } from '@angular/router'; +import { Observable } from 'rxjs/Observable'; + +@Injectable() +export class PreloadSelectedModules implements PreloadingStrategy { + preloadedModules: string[] = []; + + preload(route: Route, load: Function): Observable { + if (route.data && route.data['preload']) { + // add the route path to our preloaded module array + this.preloadedModules.push(route.path); + + // log the route path to the console + console.log('Preloaded: ' + route.path); + + return load(); + } else { + return Observable.of(null); + } + } +} diff --git a/public/docs/_examples/router/ts/plnkr.json b/public/docs/_examples/router/ts/plnkr.json index 83b1913f0e..0d7187d384 100644 --- a/public/docs/_examples/router/ts/plnkr.json +++ b/public/docs/_examples/router/ts/plnkr.json @@ -3,7 +3,7 @@ "files":[ "!**/*.d.ts", "!**/*.js", - "!**/*.[1,2,3,4,5,6].*", + "!**/*.[0-9].*", "!app/crisis-list.component.ts", "!app/hero-list.component.ts", "!app/crisis-center/add-crisis.component.ts", diff --git a/public/docs/_examples/server-communication/dart/pubspec.yaml b/public/docs/_examples/server-communication/dart/pubspec.yaml index aaf85be4d2..e3cc493935 100644 --- a/public/docs/_examples/server-communication/dart/pubspec.yaml +++ b/public/docs/_examples/server-communication/dart/pubspec.yaml @@ -5,12 +5,12 @@ version: 0.0.1 environment: sdk: '>=1.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 - http: ^0.11.3+3 + http: ^0.11.0 jsonpadding: ^0.1.0 - stream_transformers: ^0.3.0+3 + stream_transformers: ^0.3.0 http_in_memory_web_api: ^0.2.0 # #docregion transformers transformers: diff --git a/public/docs/_examples/server-communication/ts/app/app.component.ts b/public/docs/_examples/server-communication/ts/app/app.component.ts index 3a532b6524..25ada8f907 100644 --- a/public/docs/_examples/server-communication/ts/app/app.component.ts +++ b/public/docs/_examples/server-communication/ts/app/app.component.ts @@ -3,7 +3,7 @@ import { Component } from '@angular/core'; // #docregion import-rxjs -// Add the RxJS Observable operators we need in this app. +// Add the RxJS Observable operators. import './rxjs-operators'; // #enddocregion import-rxjs 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 393d52eef7..4db6aca115 100644 --- a/public/docs/_examples/server-communication/ts/app/hero-data.ts +++ b/public/docs/_examples/server-communication/ts/app/hero-data.ts @@ -3,10 +3,10 @@ import { InMemoryDbService } from 'angular-in-memory-web-api'; export class HeroData implements InMemoryDbService { createDb() { let heroes = [ - { id: '1', name: 'Windstorm' }, - { id: '2', name: 'Bombasto' }, - { id: '3', name: 'Magneta' }, - { id: '4', name: 'Tornado' } + { id: 1, name: 'Windstorm' }, + { id: 2, name: 'Bombasto' }, + { id: 3, name: 'Magneta' }, + { id: 4, name: 'Tornado' } ]; return {heroes}; } diff --git a/public/docs/_examples/server-communication/ts/app/heroes.json b/public/docs/_examples/server-communication/ts/app/heroes.json index c6b5cc91df..dfb589066b 100644 --- a/public/docs/_examples/server-communication/ts/app/heroes.json +++ b/public/docs/_examples/server-communication/ts/app/heroes.json @@ -1,8 +1,8 @@ { "data": [ - { "id": "1", "name": "Windstorm" }, - { "id": "2", "name": "Bombasto" }, - { "id": "3", "name": "Magneta" }, - { "id": "4", "name": "Tornado" } + { "id": 1, "name": "Windstorm" }, + { "id": 2, "name": "Bombasto" }, + { "id": 3, "name": "Magneta" }, + { "id": 4, "name": "Tornado" } ] } diff --git a/public/docs/_examples/server-communication/ts/app/rxjs-operators.ts b/public/docs/_examples/server-communication/ts/app/rxjs-operators.ts index 6f8d626267..0a9b9fcc88 100644 --- a/public/docs/_examples/server-communication/ts/app/rxjs-operators.ts +++ b/public/docs/_examples/server-communication/ts/app/rxjs-operators.ts @@ -2,7 +2,7 @@ // import 'rxjs/Rx'; // adds ALL RxJS statics & operators to Observable // See node_module/rxjs/Rxjs.js -// Import just the rxjs statics and operators we need for THIS app. +// Import just the rxjs statics and operators needed for THIS app. // Statics import 'rxjs/add/observable/throw'; diff --git a/public/docs/_examples/server-communication/ts/app/toh/hero-list.component.html b/public/docs/_examples/server-communication/ts/app/toh/hero-list.component.html index 36666f2ed3..65ca9cfbb7 100644 --- a/public/docs/_examples/server-communication/ts/app/toh/hero-list.component.html +++ b/public/docs/_examples/server-communication/ts/app/toh/hero-list.component.html @@ -2,13 +2,10 @@

Tour of Heroes ({{mode}})

Heroes:

    -
  • - {{hero.name}} -
  • +
  • {{hero.name}}
-New hero name: - - -
{{errorMessage}}
+ + + + +

{{errorMessage}}

diff --git a/public/docs/_examples/server-communication/ts/app/toh/hero-list.component.promise.ts b/public/docs/_examples/server-communication/ts/app/toh/hero-list.component.promise.ts index f6306f1e03..cde90d34bf 100644 --- a/public/docs/_examples/server-communication/ts/app/toh/hero-list.component.promise.ts +++ b/public/docs/_examples/server-communication/ts/app/toh/hero-list.component.promise.ts @@ -8,7 +8,8 @@ import { HeroService } from './hero.service.promise'; selector: 'hero-list-promise', moduleId: module.id, templateUrl: 'hero-list.component.html', - providers: [ HeroService ] + providers: [ HeroService ], + styles: ['.error {color:red;}'] }) // #docregion component export class HeroListPromiseComponent implements OnInit { diff --git a/public/docs/_examples/server-communication/ts/app/toh/hero-list.component.ts b/public/docs/_examples/server-communication/ts/app/toh/hero-list.component.ts index 0fa7bbad6e..f52144dcff 100644 --- a/public/docs/_examples/server-communication/ts/app/toh/hero-list.component.ts +++ b/public/docs/_examples/server-communication/ts/app/toh/hero-list.component.ts @@ -8,7 +8,8 @@ import { HeroService } from './hero.service'; moduleId: module.id, selector: 'hero-list', templateUrl: 'hero-list.component.html', - providers: [ HeroService ] + providers: [ HeroService ], + styles: ['.error {color:red;}'] }) // #docregion component export class HeroListComponent implements OnInit { diff --git a/public/docs/_examples/server-communication/ts/app/toh/hero.service.promise.ts b/public/docs/_examples/server-communication/ts/app/toh/hero.service.promise.ts index 6992eb5b6e..58fbec8e29 100644 --- a/public/docs/_examples/server-communication/ts/app/toh/hero.service.promise.ts +++ b/public/docs/_examples/server-communication/ts/app/toh/hero.service.promise.ts @@ -9,7 +9,7 @@ import { Hero } from './hero'; @Injectable() export class HeroService { // URL to web api - private heroesUrl = 'app/heroes.json'; + private heroesUrl = 'app/heroes'; constructor (private http: Http) {} @@ -22,11 +22,10 @@ export class HeroService { } addHero (name: string): Promise { - let body = JSON.stringify({ name }); let headers = new Headers({ 'Content-Type': 'application/json' }); let options = new RequestOptions({ headers: headers }); - return this.http.post(this.heroesUrl, body, options) + return this.http.post(this.heroesUrl, { name }, options) .toPromise() .then(this.extractData) .catch(this.handleError); @@ -37,12 +36,17 @@ export class HeroService { return body.data || { }; } - private handleError (error: any) { + private handleError (error: Response | any) { // In a real world app, we might use a remote logging infrastructure - // We'd also dig deeper into the error to get a better message - let errMsg = (error.message) ? error.message : - error.status ? `${error.status} - ${error.statusText}` : 'Server error'; - console.error(errMsg); // log to console instead + let errMsg: string; + if (error instanceof Response) { + const body = error.json() || ''; + const err = body.error || JSON.stringify(body); + errMsg = `${error.status} - ${error.statusText || ''} ${err}`; + } else { + errMsg = error.message ? error.message : error.toString(); + } + console.error(errMsg); return Promise.reject(errMsg); } diff --git a/public/docs/_examples/server-communication/ts/app/toh/hero.service.ts b/public/docs/_examples/server-communication/ts/app/toh/hero.service.ts index 9e970843ea..c87e70b4b8 100644 --- a/public/docs/_examples/server-communication/ts/app/toh/hero.service.ts +++ b/public/docs/_examples/server-communication/ts/app/toh/hero.service.ts @@ -34,11 +34,10 @@ export class HeroService { // #docregion addhero, addhero-sig addHero (name: string): Observable { // #enddocregion addhero-sig - let body = JSON.stringify({ name }); let headers = new Headers({ 'Content-Type': 'application/json' }); let options = new RequestOptions({ headers: headers }); - return this.http.post(this.heroesUrl, body, options) + return this.http.post(this.heroesUrl, { name }, options) .map(this.extractData) .catch(this.handleError); } @@ -50,14 +49,19 @@ export class HeroService { return body.data || { }; } // #enddocregion extract-data - // #docregion error-handling - private handleError (error: any) { + + private handleError (error: Response | any) { // In a real world app, we might use a remote logging infrastructure - // We'd also dig deeper into the error to get a better message - let errMsg = (error.message) ? error.message : - error.status ? `${error.status} - ${error.statusText}` : 'Server error'; - console.error(errMsg); // log to console instead + let errMsg: string; + if (error instanceof Response) { + const body = error.json() || ''; + const err = body.error || JSON.stringify(body); + errMsg = `${error.status} - ${error.statusText || ''} ${err}`; + } else { + errMsg = error.message ? error.message : error.toString(); + } + console.error(errMsg); return Observable.throw(errMsg); } // #enddocregion error-handling, methods diff --git a/public/docs/_examples/server-communication/ts/app/wiki/wiki-smart.component.ts b/public/docs/_examples/server-communication/ts/app/wiki/wiki-smart.component.ts index e6bbce139b..97ca33e1c0 100644 --- a/public/docs/_examples/server-communication/ts/app/wiki/wiki-smart.component.ts +++ b/public/docs/_examples/server-communication/ts/app/wiki/wiki-smart.component.ts @@ -1,3 +1,5 @@ +/* tslint:disable: member-ordering forin */ +// #docplaster // #docregion import { Component } from '@angular/core'; import { Observable } from 'rxjs/Observable'; @@ -8,33 +10,27 @@ import { Subject } from 'rxjs/Subject'; import { WikipediaService } from './wikipedia.service'; @Component({ + moduleId: module.id, selector: 'my-wiki-smart', - template: ` -

Smarter Wikipedia Demo

-

Fetches when typing stops

- - - -
    -
  • {{item}}
  • -
- `, - providers: [WikipediaService] + templateUrl: 'wiki.component.html', + providers: [ WikipediaService ] }) export class WikiSmartComponent { - - constructor (private wikipediaService: WikipediaService) { } + title = 'Smarter Wikipedia Demo'; + fetches = 'Fetches when typing stops'; + items: Observable; // #docregion subject private searchTermStream = new Subject(); - search(term: string) { this.searchTermStream.next(term); } // #enddocregion subject - // #docregion observable-operators - items: Observable = this.searchTermStream - .debounceTime(300) - .distinctUntilChanged() - .switchMap((term: string) => this.wikipediaService.search(term)); -// #enddocregion observable-operators + constructor (private wikipediaService: WikipediaService) { + // #docregion observable-operators + this.items = this.searchTermStream + .debounceTime(300) + .distinctUntilChanged() + .switchMap((term: string) => this.wikipediaService.search(term)); + // #enddocregion observable-operators + } } diff --git a/public/docs/_examples/server-communication/ts/app/wiki/wiki.component.html b/public/docs/_examples/server-communication/ts/app/wiki/wiki.component.html new file mode 100644 index 0000000000..e94d37f3aa --- /dev/null +++ b/public/docs/_examples/server-communication/ts/app/wiki/wiki.component.html @@ -0,0 +1,11 @@ + +

{{title}}

+

{{fetches}}

+ + + + + +
    +
  • {{item}}
  • +
diff --git a/public/docs/_examples/server-communication/ts/app/wiki/wiki.component.ts b/public/docs/_examples/server-communication/ts/app/wiki/wiki.component.ts index 92c31afb80..f72f005460 100644 --- a/public/docs/_examples/server-communication/ts/app/wiki/wiki.component.ts +++ b/public/docs/_examples/server-communication/ts/app/wiki/wiki.component.ts @@ -5,25 +5,19 @@ import { Observable } from 'rxjs/Observable'; import { WikipediaService } from './wikipedia.service'; @Component({ + moduleId: module.id, selector: 'my-wiki', - template: ` -

Wikipedia Demo

-

Fetches after each keystroke

- - - -
    -
  • {{item}}
  • -
- `, - providers: [WikipediaService] + templateUrl: 'wiki.component.html', + providers: [ WikipediaService ] }) export class WikiComponent { + title = 'Wikipedia Demo'; + fetches = 'Fetches after each keystroke'; items: Observable; - constructor (private wikipediaService: WikipediaService) {} - search (term: string) { this.items = this.wikipediaService.search(term); } + + constructor (private wikipediaService: WikipediaService) { } } diff --git a/public/docs/_examples/server-communication/ts/index.html b/public/docs/_examples/server-communication/ts/index.html index d265bef2f9..6b99fc5242 100644 --- a/public/docs/_examples/server-communication/ts/index.html +++ b/public/docs/_examples/server-communication/ts/index.html @@ -6,8 +6,6 @@ - - diff --git a/public/docs/_examples/server-communication/ts/sample.css b/public/docs/_examples/server-communication/ts/sample.css deleted file mode 100644 index 3bb281e096..0000000000 --- a/public/docs/_examples/server-communication/ts/sample.css +++ /dev/null @@ -1 +0,0 @@ -.error {color:red;} diff --git a/public/docs/_examples/structural-directives/dart/pubspec.yaml b/public/docs/_examples/structural-directives/dart/pubspec.yaml index 46542a7424..5d6f88d490 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/template-syntax/dart/pubspec.yaml b/public/docs/_examples/template-syntax/dart/pubspec.yaml index f53eb65de1..7de95f550e 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/template-syntax/e2e-spec.ts b/public/docs/_examples/template-syntax/e2e-spec.ts index 124f633280..b8621c4d2d 100644 --- a/public/docs/_examples/template-syntax/e2e-spec.ts +++ b/public/docs/_examples/template-syntax/e2e-spec.ts @@ -1,4 +1,4 @@ -'use strict'; // necessary for es6 output in node +'use strict'; // necessary for es6 output in node import { browser, element, by } from 'protractor'; @@ -30,4 +30,15 @@ describe('Template Syntax', function () { let specialButtonEle = element(by.cssContainingText('div.special~button', 'button')); expect(specialButtonEle.getAttribute('style')).toMatch('color: red'); }); + + it('should two-way bind to sizer', function () { + let buttons = element.all(by.css('div#two-way-1 my-sizer button')); + let input = element(by.css('input#fontsize')); + + input.getAttribute('value').then(size => { + buttons.get(1).click(); + browser.waitForAngular(); + expect(input.getAttribute('value')).toEqual((+size + 1).toString()); + }); + }); }); diff --git a/public/docs/_examples/template-syntax/ts/app/app.component.html b/public/docs/_examples/template-syntax/ts/app/app.component.html index 50c07a1fc8..d844154f58 100644 --- a/public/docs/_examples/template-syntax/ts/app/app.component.html +++ b/public/docs/_examples/template-syntax/ts/app/app.component.html @@ -14,7 +14,7 @@
Event Binding
- +Two-way Binding

Directives
@@ -242,9 +242,6 @@ button - - -
@@ -349,9 +346,26 @@ button

- top +

Two-way Binding

+
+ + +
Resizable Text
+ + +
+
+
+

De-sugared two-way binding

+ + + +
+

+ +top

NgModel (two-way) Binding

diff --git a/public/docs/_examples/template-syntax/ts/app/app.component.ts b/public/docs/_examples/template-syntax/ts/app/app.component.ts index fb128c88d8..072c634162 100644 --- a/public/docs/_examples/template-syntax/ts/app/app.component.ts +++ b/public/docs/_examples/template-syntax/ts/app/app.component.ts @@ -1,4 +1,4 @@ -/* tslint:disable forin */ +/* tslint:disable:forin member-ordering */ // #docplaster import { AfterViewInit, Component, ElementRef, OnInit, QueryList, ViewChildren } from '@angular/core'; @@ -50,6 +50,8 @@ export class AppComponent implements AfterViewInit, OnInit { this.alert('Deleted hero: ' + (hero && hero.firstName)); } + fontSize = 10; + // #docregion evil-title evilTitle = 'Template Syntax'; // #enddocregion evil-title diff --git a/public/docs/_examples/template-syntax/ts/app/app.module.ts b/public/docs/_examples/template-syntax/ts/app/app.module.ts index 2a99d8b395..db940fad08 100644 --- a/public/docs/_examples/template-syntax/ts/app/app.module.ts +++ b/public/docs/_examples/template-syntax/ts/app/app.module.ts @@ -5,6 +5,7 @@ import { FormsModule } from '@angular/forms'; import { AppComponent } from './app.component'; import { BigHeroDetailComponent, HeroDetailComponent } from './hero-detail.component'; import { MyClickDirective, MyClickDirective2 } from './my-click.directive'; +import { SizerComponent } from './sizer.component'; @NgModule({ imports: [ @@ -16,7 +17,8 @@ import { MyClickDirective, MyClickDirective2 } from './my-click.directive'; BigHeroDetailComponent, HeroDetailComponent, MyClickDirective, - MyClickDirective2 + MyClickDirective2, + SizerComponent ], bootstrap: [ AppComponent ] }) diff --git a/public/docs/_examples/template-syntax/ts/app/sizer.component.ts b/public/docs/_examples/template-syntax/ts/app/sizer.component.ts new file mode 100644 index 0000000000..cf0ef4af47 --- /dev/null +++ b/public/docs/_examples/template-syntax/ts/app/sizer.component.ts @@ -0,0 +1,25 @@ +// #docregion +import { Component, EventEmitter, Input, Output } from '@angular/core'; + +@Component({ + selector: 'my-sizer', + template: ` +
+ + + +
` +}) +export class SizerComponent { + @Input() size: number; + @Output() sizeChange = new EventEmitter(); + + dec() { this.resize(-1); } + inc() { this.resize(+1); } + + resize(delta: number) { + const size = +this.size + delta; + this.size = Math.min(40, Math.max(8, size)); + this.sizeChange.emit(this.size); + } +} diff --git a/public/docs/_examples/testing/ts/karma-test-shim.js b/public/docs/_examples/testing/ts/karma-test-shim.js index 19fcc89fe9..cce63112b2 100644 --- a/public/docs/_examples/testing/ts/karma-test-shim.js +++ b/public/docs/_examples/testing/ts/karma-test-shim.js @@ -28,7 +28,7 @@ var allSpecFiles = Object.keys(window.__karma__.files) .filter(isBuiltFile); System.config({ - baseURL: '/base', + baseURL: 'base', // Extend usual application package list with test folder packages: { 'testing': { main: 'index.js', defaultExtension: 'js' } }, diff --git a/public/docs/_examples/testing/ts/karma.conf.js b/public/docs/_examples/testing/ts/karma.conf.js index 1e2d293721..ed1b251a2c 100644 --- a/public/docs/_examples/testing/ts/karma.conf.js +++ b/public/docs/_examples/testing/ts/karma.conf.js @@ -3,7 +3,7 @@ module.exports = function(config) { var appBase = 'app/'; // transpiled app JS and map files var appSrcBase = 'app/'; // app source TS files - var appAssets = '/base/app/'; // component assets fetched by Angular's compiler + var appAssets = 'base/app/'; // component assets fetched by Angular's compiler var testBase = 'testing/'; // transpiled test JS and map files var testSrcBase = 'testing/'; // test source TS files diff --git a/public/docs/_examples/toh-1/dart/pubspec.yaml b/public/docs/_examples/toh-1/dart/pubspec.yaml index 4cd2834c35..af57cdc274 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/toh-2/dart/pubspec.yaml b/public/docs/_examples/toh-2/dart/pubspec.yaml index 4cd2834c35..af57cdc274 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/toh-3/dart/pubspec.yaml b/public/docs/_examples/toh-3/dart/pubspec.yaml index 4cd2834c35..af57cdc274 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/toh-4/dart/pubspec.yaml b/public/docs/_examples/toh-4/dart/pubspec.yaml index 4cd2834c35..af57cdc274 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: 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 ba1ed39c88..9bc62a3477 100644 --- a/public/docs/_examples/toh-5/dart/lib/app_component.dart +++ b/public/docs/_examples/toh-5/dart/lib/app_component.dart @@ -28,7 +28,7 @@ import 'heroes_component.dart'; directives: const [ROUTER_DIRECTIVES], providers: const [HeroService, ROUTER_PROVIDERS]) // #enddocregion directives-and-providers -// #docregion heroes +// #docregion heroes, routes @RouteConfig(const [ // #enddocregion heroes // #docregion dashboard @@ -45,7 +45,7 @@ import 'heroes_component.dart'; // #docregion heroes const Route(path: '/heroes', name: 'Heroes', component: HeroesComponent) ]) -// #enddocregion heroes +// #enddocregion heroes, routes class AppComponent { String title = 'Tour of Heroes'; } diff --git a/public/docs/_examples/toh-5/dart/pubspec.yaml b/public/docs/_examples/toh-5/dart/pubspec.yaml index 4cd2834c35..af57cdc274 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/toh-6/dart/pubspec.yaml b/public/docs/_examples/toh-6/dart/pubspec.yaml index 2c43d9deae..9f4b826c5c 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.19.0 <2.0.0' # #docregion additions dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 # #enddocregion additions browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 diff --git a/public/docs/_examples/toh-6/ts/aot/index.html b/public/docs/_examples/toh-6/ts/aot/index.html index d42f3e0574..1a64ca8cac 100644 --- a/public/docs/_examples/toh-6/ts/aot/index.html +++ b/public/docs/_examples/toh-6/ts/aot/index.html @@ -6,6 +6,8 @@ Angular Tour of Heroes + + 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 8ddf858972..c0933e4697 100644 --- a/public/docs/_examples/toh-6/ts/app/app.module.ts +++ b/public/docs/_examples/toh-6/ts/app/app.module.ts @@ -14,7 +14,7 @@ import { AppRoutingModule } from './app-routing.module'; // #enddocregion v1 // Imports for loading & configuring the in-memory web api -import { InMemoryWebApiModule } from 'angular-in-memory-web-api/in-memory-web-api.module'; +import { InMemoryWebApiModule } from 'angular-in-memory-web-api'; import { InMemoryDataService } from './in-memory-data.service'; // #docregion v1 diff --git a/public/docs/_examples/toh-6/ts/copy-dist-files.js b/public/docs/_examples/toh-6/ts/copy-dist-files.js index 288e35a62c..660dadf55b 100644 --- a/public/docs/_examples/toh-6/ts/copy-dist-files.js +++ b/public/docs/_examples/toh-6/ts/copy-dist-files.js @@ -2,7 +2,8 @@ var fs = require('fs'); var resources = [ 'node_modules/core-js/client/shim.min.js', - 'node_modules/zone.js/dist/zone.min.js' + 'node_modules/zone.js/dist/zone.min.js', + 'styles.css' ]; resources.map(function(f) { var path = f.split('/'); diff --git a/public/docs/_examples/toh-6/ts/rollup-config.js b/public/docs/_examples/toh-6/ts/rollup-config.js index 4b42351c50..aeb227689c 100644 --- a/public/docs/_examples/toh-6/ts/rollup-config.js +++ b/public/docs/_examples/toh-6/ts/rollup-config.js @@ -12,13 +12,10 @@ export default { sourceMapFile: 'aot/dist/build.js.map', format: 'iife', plugins: [ - nodeResolve({jsnext: true, module: true}), - commonjs({ - include: [ - 'node_modules/rxjs/**', - 'node_modules/angular-in-memory-web-api/**' - ], - }), - uglify() + nodeResolve({jsnext: true, module: true}), + commonjs({ + include: ['node_modules/rxjs/**'] + }), + uglify() ] } diff --git a/public/docs/_examples/toh-6/ts/tsconfig-aot.json b/public/docs/_examples/toh-6/ts/tsconfig-aot.json index 1d1983af4c..97d6f592a0 100644 --- a/public/docs/_examples/toh-6/ts/tsconfig-aot.json +++ b/public/docs/_examples/toh-6/ts/tsconfig-aot.json @@ -9,13 +9,14 @@ "removeComments": false, "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true, - "types": [] + "typeRoots": [ + "../../node_modules/@types/" + ] }, "files": [ "app/app.module.ts", - "app/main-aot.ts", - "typings/index.d.ts" + "app/main-aot.ts" ], "angularCompilerOptions": { diff --git a/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/app/main.ts b/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/app/main.ts index 55bb1fe183..06c61fd0d4 100644 --- a/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/app/main.ts +++ b/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/app/main.ts @@ -1,5 +1,6 @@ // #docregion import-adapter import { UpgradeAdapter } from '@angular/upgrade'; +declare var angular: any; import { AppModule } from './app.module'; // #enddocregion import-adapter diff --git a/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/app/phone-detail/phone-detail.component.ng1.ts b/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/app/phone-detail/phone-detail.component.ng1.ts index b458343ece..333c08aa45 100644 --- a/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/app/phone-detail/phone-detail.component.ng1.ts +++ b/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/app/phone-detail/phone-detail.component.ng1.ts @@ -1,5 +1,6 @@ // #docregion import { Phone, PhoneData } from '../core/phone/phone.service'; +declare var angular: any; class PhoneDetailController { phone: PhoneData; diff --git a/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/app/phone-list/phone-list.component.ng1.ts b/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/app/phone-list/phone-list.component.ng1.ts index 6b36772a72..47b1e35e4a 100644 --- a/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/app/phone-list/phone-list.component.ng1.ts +++ b/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/app/phone-list/phone-list.component.ng1.ts @@ -1,5 +1,6 @@ // #docregion import { Phone, PhoneData } from '../core/phone/phone.service'; +declare var angular: any; class PhoneListController { phones: PhoneData[]; diff --git a/public/docs/_examples/user-input/dart/pubspec.yaml b/public/docs/_examples/user-input/dart/pubspec.yaml index 3d885ba12d..07a934d480 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.19.0 <2.0.0' dependencies: - angular2: 2.0.0-beta.22 + angular2: ^2.0.0 browser: ^0.10.0 dart_to_js_script_rewriter: ^1.0.1 transformers: diff --git a/public/docs/_examples/webpack/ts/config/webpack.common.js b/public/docs/_examples/webpack/ts/config/webpack.common.js index b707349719..771294130e 100644 --- a/public/docs/_examples/webpack/ts/config/webpack.common.js +++ b/public/docs/_examples/webpack/ts/config/webpack.common.js @@ -15,7 +15,7 @@ module.exports = { // #docregion resolve resolve: { - extensions: ['', '.js', '.ts'] + extensions: ['', '.ts', '.js'] }, // #enddocregion resolve diff --git a/public/docs/_examples/webpack/ts/package.webpack.json b/public/docs/_examples/webpack/ts/package.webpack.json index 6f3eb15a3e..ed36c0f33f 100644 --- a/public/docs/_examples/webpack/ts/package.webpack.json +++ b/public/docs/_examples/webpack/ts/package.webpack.json @@ -5,8 +5,7 @@ "scripts": { "start": "webpack-dev-server --inline --progress --port 8080", "test": "karma start", - "build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail", - "postinstall": "typings install" + "build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail" }, "licenses": [ { @@ -15,19 +14,22 @@ } ], "dependencies": { - "@angular/common": "~2.1.0", - "@angular/compiler": "~2.1.0", - "@angular/core": "~2.1.0", - "@angular/forms": "~2.1.0", - "@angular/http": "~2.1.0", - "@angular/platform-browser": "~2.1.0", - "@angular/platform-browser-dynamic": "~2.1.0", - "@angular/router": "~3.1.0", + "@angular/common": "~2.1.1", + "@angular/compiler": "~2.1.1", + "@angular/core": "~2.1.1", + "@angular/forms": "~2.1.1", + "@angular/http": "~2.1.1", + "@angular/platform-browser": "~2.1.1", + "@angular/platform-browser-dynamic": "~2.1.1", + "@angular/router": "~3.1.1", "core-js": "^2.4.1", "rxjs": "5.0.0-beta.12", "zone.js": "^0.6.25" }, "devDependencies": { + "@types/core-js": "^0.9.34", + "@types/node": "^6.0.45", + "@types/jasmine": "^2.5.35", "angular2-template-loader": "^0.4.0", "awesome-typescript-loader": "^2.2.4", "css-loader": "^0.23.1", @@ -46,8 +48,7 @@ "raw-loader": "^0.5.1", "rimraf": "^2.5.2", "style-loader": "^0.13.1", - "typescript": "^2.0.2", - "typings": "^1.3.2", + "typescript": "^2.0.3", "webpack": "^1.13.0", "webpack-dev-server": "^1.14.1", "webpack-merge": "^0.14.0" diff --git a/public/docs/_examples/webpack/ts/typings.1.json b/public/docs/_examples/webpack/ts/typings.1.json deleted file mode 100644 index 7da31ca0af..0000000000 --- a/public/docs/_examples/webpack/ts/typings.1.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "globalDependencies": { - "core-js": "registry:dt/core-js#0.0.0+20160725163759", - "jasmine": "registry:dt/jasmine#2.2.0+20160621224255", - "node": "registry:dt/node#6.0.0+20160909174046" - } -} diff --git a/public/docs/dart/latest/_data.json b/public/docs/dart/latest/_data.json index fe573bba26..31180217a5 100644 --- a/public/docs/dart/latest/_data.json +++ b/public/docs/dart/latest/_data.json @@ -4,7 +4,7 @@ "title": "Angular Docs", "subtitle": "Dart", "menuTitle": "Docs Home", - "banner": "Angular release is beta.22. View the change log to see enhancements, fixes, and breaking changes." + "banner": "AngularDart is 2.0. View the change log to see enhancements, fixes, and breaking changes." }, "quickstart": { @@ -23,7 +23,7 @@ "guide": { "icon": "list", - "title": "Developer Guides", + "title": "Guide", "subtitle": "Dart" }, diff --git a/public/docs/dart/latest/_util-fns.jade b/public/docs/dart/latest/_util-fns.jade index a4a0cf461c..741d5b0c99 100644 --- a/public/docs/dart/latest/_util-fns.jade +++ b/public/docs/dart/latest/_util-fns.jade @@ -29,20 +29,6 @@ include ../../../_includes/_util-fns - var _moduleVsRootComp = 'root component' - var _platformBrowserDynamicVsBootStrap = 'bootstrap' -//- Deprecated -mixin liveExampleLink(linkText, exampleUrlPartName) - - var text = linkText || '在线例子'; - - var ex = exampleUrlPartName || getExampleName(); - - var href = 'http://angular-examples.github.io/' + ex; - a(href='#{href}' target="_blank")= text - -//- Deprecated -mixin liveExampleLink2(linkText, exampleUrlPartName) - - var srcText = attributes.srcText || '查看源码'; - - var ex = exampleUrlPartName || attributes.example || getExampleName(); - - var href = 'http://github.com/angular-examples/' + ex; - span #[+liveExampleLink(linkText, ex)] (#[a(href='#{href}' target="_blank") #{srcText}]) - - var adjustTsExamplePathForDart = function(_path) { - if(!_path) return _path; - var path = _path.trim(); diff --git a/public/docs/dart/latest/api/_data.json b/public/docs/dart/latest/api/_data.json new file mode 100644 index 0000000000..6bb33fa9a7 --- /dev/null +++ b/public/docs/dart/latest/api/_data.json @@ -0,0 +1,5 @@ +{ + "index" : { + "title" : "API Reference" + } +} diff --git a/public/docs/dart/latest/api/index.jade b/public/docs/dart/latest/api/index.jade new file mode 100644 index 0000000000..477cf84fb3 --- /dev/null +++ b/public/docs/dart/latest/api/index.jade @@ -0,0 +1,9 @@ +:marked + > **Known issues:** The angular.io issue tracker contains [all known + issues][api-issues]; if you notice others, please [report + them][new-issue]. Thanks! + + [new-issue]: https://github.com/angular/angular.io/issues/new?labels=dart,api&title=%5BDart%5D%5BAPI%5D%20 + [api-issues]: https://github.com/angular/angular.io/issues?q=label%3Aapi+label%3Adart + +api-list(src="api-list.json" lang="dart") diff --git a/public/docs/dart/latest/quickstart.jade b/public/docs/dart/latest/quickstart.jade index ee8ea0e87a..50e3d516ab 100644 --- a/public/docs/dart/latest/quickstart.jade +++ b/public/docs/dart/latest/quickstart.jade @@ -30,7 +30,6 @@ 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.22**. [pubspec]: https://www.dartlang.org/tools/pub/pubspec.html diff --git a/public/docs/js/latest/_data.json b/public/docs/js/latest/_data.json index 2ecac642b6..6774cfc012 100644 --- a/public/docs/js/latest/_data.json +++ b/public/docs/js/latest/_data.json @@ -23,7 +23,7 @@ "guide": { "icon": "list", - "title": "Developer Guides", + "title": "Guide", "subtitle": "JavaScript" }, diff --git a/public/docs/js/latest/guide/forms.jade b/public/docs/js/latest/guide/forms.jade index b0148eae79..e51a6f01b0 100644 --- a/public/docs/js/latest/guide/forms.jade +++ b/public/docs/js/latest/guide/forms.jade @@ -624,11 +624,9 @@ figure.image-display .file hero-form.component.js .file main.ts .file node_modules ... - .file typings ... .file index.html .file package.json .file tsconfig.json - .file typings.json :marked Here’s the final version of the source: diff --git a/public/docs/js/latest/quickstart.jade b/public/docs/js/latest/quickstart.jade index 7c3f31ed14..baa7ea01fc 100644 --- a/public/docs/js/latest/quickstart.jade +++ b/public/docs/js/latest/quickstart.jade @@ -482,7 +482,7 @@ code-example(format=""). 1. Which components and directives we declare in our components 1. The component to bootstrap at the start - We import our lone `app.AppComponent` and add it to both `declaration` and `bootstrap` array. + We import our lone `app.AppComponent` and add it to both `declarations` and `bootstrap` array. Notice that we also add `ng.platformBrowser.BrowserModule` to the `imports` array. This is the Angular Module that contains all the needed Angular bits and pieces to run our app in the browser. diff --git a/public/docs/ts/_cache/guide/architecture.jade b/public/docs/ts/_cache/guide/architecture.jade index 3510c864bb..6456f9b46c 100644 --- a/public/docs/ts/_cache/guide/architecture.jade +++ b/public/docs/ts/_cache/guide/architecture.jade @@ -41,7 +41,7 @@ figure Learn these, and we're on our way. .l-sub-section - p The code referenced in this chapter is available as a #[+liveExampleLink2()]. + p The code referenced in this chapter is available as a . .l-main-section :marked diff --git a/public/docs/ts/_cache/quickstart.jade b/public/docs/ts/_cache/quickstart.jade index 95faaf7a84..d59ae2431b 100644 --- a/public/docs/ts/_cache/quickstart.jade +++ b/public/docs/ts/_cache/quickstart.jade @@ -581,13 +581,11 @@ block project-file-structure .file app.module.ts .file main.ts .file node_modules ... - .file typings ... .file index.html .file package.json .file styles.css .file systemjs.config.js .file tsconfig.json - .file typings.json :marked Here are the file contents: @@ -599,7 +597,6 @@ block project-files quickstart/ts/index.html, quickstart/ts/package.1.json, quickstart/ts/tsconfig.1.json, - quickstart/ts/typings.1.json, quickstart/ts/styles.css, quickstart/ts/systemjs.config.1.js` , @@ -610,7 +607,6 @@ block project-files index.html, package.json, tsconfig.json, - typings.json, styles.css (excerpt), systemjs.config.js`) diff --git a/public/docs/ts/_cache/tutorial/toh-pt5.jade b/public/docs/ts/_cache/tutorial/toh-pt5.jade index f0adefb421..67f14e41a1 100644 --- a/public/docs/ts/_cache/tutorial/toh-pt5.jade +++ b/public/docs/ts/_cache/tutorial/toh-pt5.jade @@ -64,13 +64,11 @@ block intro-file-tree .file main.ts .file mock-heroes.ts .file node_modules ... - .file typings ... .file index.html .file package.json .file styles.css .file systemjs.config.js .file tsconfig.json - .file typings.json block keep-app-running :marked @@ -883,13 +881,11 @@ block file-tree-end .file main.ts .file mock-heroes.ts .file node_modules ... - .file typings ... .file index.html .file package.json .file styles.css .file systemjs.config.js .file tsconfig.json - .file typings.json .l-main-section :marked diff --git a/public/docs/ts/_cache/tutorial/toh-pt6.jade b/public/docs/ts/_cache/tutorial/toh-pt6.jade index 54c2b2e22c..007e6e77f7 100644 --- a/public/docs/ts/_cache/tutorial/toh-pt6.jade +++ b/public/docs/ts/_cache/tutorial/toh-pt6.jade @@ -559,13 +559,11 @@ block filetree .file main.ts .file in-memory-data.service.ts (new) .file node_modules ... - .file typings ... .file index.html .file package.json .file styles.css .file systemjs.config.js .file tsconfig.json - .file typings.json .l-main-section :marked diff --git a/public/docs/ts/latest/_util-fns.jade b/public/docs/ts/latest/_util-fns.jade index 1fae0b83ce..7635f5f56f 100644 --- a/public/docs/ts/latest/_util-fns.jade +++ b/public/docs/ts/latest/_util-fns.jade @@ -3,15 +3,3 @@ include ../../../_includes/_util-fns //- See the _util-fns file included above for a description of the use of these variables. - var _docsFor = 'ts'; //- Other values match the defaults. - -//- Deprecated -mixin liveExampleLink(linkText, exampleUrlPartName) - - var text = linkText || 'live example'; - - var ex = exampleUrlPartName || getExampleName(); - - var href = '/resources/live-examples/' + ex + '/ts/plnkr.html'; - a(href='#{href}' target="_blank")= text - -//- Deprecated -mixin liveExampleLink2(linkText, exampleUrlPartName) - //- In Dart this gives 2 links: to the demo and to the source. - +liveExampleLink(linkText, exampleUrlPartName) diff --git a/public/docs/ts/latest/cookbook/aot-compiler.jade b/public/docs/ts/latest/cookbook/aot-compiler.jade index 37f5ab90f3..045626eb17 100644 --- a/public/docs/ts/latest/cookbook/aot-compiler.jade +++ b/public/docs/ts/latest/cookbook/aot-compiler.jade @@ -646,8 +646,8 @@ a#toh `toh-6/ts/tsconfig-aot.json, toh-6/ts/tsconfig.json`, null, - `tsconfig.json (AoT), - tsconfig-aot.json (JiT)` + `tsconfig-aot.json (AoT), + tsconfig.json (JiT)` ) :marked @@ -659,18 +659,6 @@ a#toh Rollup和以前一样,仍然进行摇树优化。 - The Rollup configuration changes slightly to accommodate the `angular-in-memory-web-api` module - that the _Tour of Heroes_ app requires for data server simulation. - - Rollup配置有很小的变化,以适应**英雄指南**应用需要的数据服务模拟 - `angular-in-memory-web-api`模块。 - - The `angular-in-memory-web-api` is a `commonjs` module like the RxJS library. - Add `angular-in-memory-web-api` to the _commonjs plugin_ `include` array, - next to the `rxjs` file specification. - - `angular-in-memory-web-api`是一个`commonjs`模块,和RxJS库一样。 - 添加`angular-in-memory-web-api`到**commonjs插件**`include`数组,紧挨着`RxJS`文件配置。 - +makeExample('toh-6/ts/rollup-config.js',null,'rollup-config.js')(format='.') :marked diff --git a/public/docs/ts/latest/cookbook/component-communication.jade b/public/docs/ts/latest/cookbook/component-communication.jade index 691fc0a0ed..205bbb91bd 100644 --- a/public/docs/ts/latest/cookbook/component-communication.jade +++ b/public/docs/ts/latest/cookbook/component-communication.jade @@ -337,7 +337,7 @@ a(id="countdown-tests") +makeExample('cb-component-communication/ts/app/countdown-parent.component.ts', 'vc') :marked - It takes a bit more work to get the child view into the parent component classs. + It takes a bit more work to get the child view into the parent component *class*. 把子组件的视图插入到父组件类需要做一点额外的工作。 diff --git a/public/docs/ts/latest/glossary.jade b/public/docs/ts/latest/glossary.jade index e2871ffccd..10f8886c3a 100644 --- a/public/docs/ts/latest/glossary.jade +++ b/public/docs/ts/latest/glossary.jade @@ -58,7 +58,7 @@ block includes 帮助我们将一个应用程序组织成拼合的功能模块群。一个Angular模块标识了被应用程序使用的组件、指令和管道等,它同时包含了应用程序需要的外来Angular模块的列表,比如`FormsModule`。 - Every Angular application has an application root module class. By convention the class is + Every Angular application has an application root module class. By convention, the class is called `AppModule` and resides in a file named `app.module.ts`. 每个Angular应用程序都有一个应用程序根模块类。按规约这个类的名字为`AppModule`,存放在名为`app.module.ts`的文件。 diff --git a/public/docs/ts/latest/guide/animations.jade b/public/docs/ts/latest/guide/animations.jade index 23b469a5a0..ca08f9148c 100644 --- a/public/docs/ts/latest/guide/animations.jade +++ b/public/docs/ts/latest/guide/animations.jade @@ -293,6 +293,16 @@ figure 注意,在这个例子中,这些样式在转场定义中被直接应用到了`void`状态,但并没有一个单独的`state(void)`定义。 这么做是因为希望在进场与离场时使用不一样的转换效果:元素从左侧进场,从右侧离开。 +.l-sub-section + :marked + These two common animations have their own aliases: + + 这两个常见的动画有自己的别名: + code-example(language="typescript"). + transition(':enter', [ ... ]); // void => * + transition(':leave', [ ... ]); // * => void + +:marked ## Example: Entering and leaving from different states ## 范例:从不同的状态下进场和离场 diff --git a/public/docs/ts/latest/guide/architecture.jade b/public/docs/ts/latest/guide/architecture.jade index 3b66430c88..514c4bc037 100644 --- a/public/docs/ts/latest/guide/architecture.jade +++ b/public/docs/ts/latest/guide/architecture.jade @@ -82,7 +82,7 @@ figure .l-sub-section - p The code referenced on this page is available as a #[+liveExampleLink2()]. + p The code referenced on this page is available as a . p 本章所引用的代码可以从这个#[+liveExampleLink2('在线例子')]。 diff --git a/public/docs/ts/latest/guide/change-log.jade b/public/docs/ts/latest/guide/change-log.jade index 6e67479863..812668ec42 100644 --- a/public/docs/ts/latest/guide/change-log.jade +++ b/public/docs/ts/latest/guide/change-log.jade @@ -11,6 +11,34 @@ block includes 我们将持续不断的更新和改进Angular文档。本日志记录了近期最重要的变更。 + ## Sync with Angular v.2.1.1 (2016-10-21) + Docs and code samples updated and tested with Angular v.2.1.0 + + ## npm _@types_ packages replace _typings_ (2016-10-20) + Documentation samples now get TypeScript type information for 3rd party libraries + from npm `@types` packages rather than with the _typings_ tooling. + The `typings.json` file is gone. + + The "[Angular 1 Upgrade](upgrade.html)" guide reflects this change. + The `package.json` installs `@types/angular` and several `@types/angular-...` + packages in support of upgrade; these are not needed for pure Angular 2 development. + + ## "Template Syntax" explains two-way data binding syntax (2016-10-20) + Demonstrates how to two-way data bind to a custom Angular component and + re-explains `[(ngModel)]` in terms of the basic `[()]` syntax. + + ## BREAKING CHANGE: `in-memory-web-api` (v.0.1.11) delivered as esm umd (2016-10-19) + This change supports ES6 developers and aligns better with typical Angular libraries. + It does not affect the module's API but it does affect how you load and import it. + See the change note + in the `in-memory-web-api` repo. + + ## "Router" _preload_ syntax and _:enter_/_:leave_ animations (2016-10-19) + The router can lazily _preload_ modules _after_ the app starts and + _before_ the user navigates to them for improved perceived performance. + + New `:enter` and `:leave` aliases make animation more natural. + ## Sync with Angular v.2.1.0 (2016-10-12) ## 与Angular v.2.1.0同步(2016-10-12) diff --git a/public/docs/ts/latest/guide/forms.jade b/public/docs/ts/latest/guide/forms.jade index e53723b06f..e613815975 100644 --- a/public/docs/ts/latest/guide/forms.jade +++ b/public/docs/ts/latest/guide/forms.jade @@ -1274,12 +1274,10 @@ figure.image-display .file hero-form.component.html .file hero-form.component.ts .file main.ts - .file node_modules ... - .file typings ... + .file node_modules ... .file index.html .file package.json .file tsconfig.json - .file typings.json :marked Here’s the final version of the source: diff --git a/public/docs/ts/latest/guide/npm-packages.jade b/public/docs/ts/latest/guide/npm-packages.jade index 25773d4c77..9c7646a350 100644 --- a/public/docs/ts/latest/guide/npm-packages.jade +++ b/public/docs/ts/latest/guide/npm-packages.jade @@ -258,16 +258,18 @@ a(id="dev-dependencies") 由[John Papa](http://johnpapa.net/)开发和维护。对使用到路由的Angular程序提供了很好的支持。 ***[typescript](https://www.npmjs.com/package/typescript)*** - - The TypeScript language server, including the *tsc* TypeScript compiler. + the TypeScript language server, including the *tsc* TypeScript compiler. ***[typescript](https://www.npmjs.com/package/typescript)*** - TypeScript语言的服务器,包含了TypeScript编译器*tsc*。 - ***[typings](https://www.npmjs.com/package/typings)*** - A manager for TypeScript definition files. - Read more about it in the [TypeScript Configuration](typescript-configuration.html#typings) page. + ***@types/\**** - TypeScript definition files. + Learn more about it in the [TypeScript Configuration](typescript-configuration.html#typings) chapter. - ***[typings](https://www.npmjs.com/package/typings)*** - 一个“TypeScript定义”文件管理器。 + ***@types/\**** - “TypeScript定义”文件管理器。 要了解更多,请参见[TypeScript配置](typescript-configuration.html#typings)页。 + + .l-main-section a(id="why-peer-dependencies") :marked diff --git a/public/docs/ts/latest/guide/router.jade b/public/docs/ts/latest/guide/router.jade index d7985c00a1..701ad5c10f 100644 --- a/public/docs/ts/latest/guide/router.jade +++ b/public/docs/ts/latest/guide/router.jade @@ -159,6 +159,14 @@ include ../_util-fns * [异步](#asynchronous-routing)加载特性分区 + * pre-loading feature areas [during navigation](#preloading) + + * [在导航时](#preloading)预加载特性分区 + + * using a [custom strategy](#custom-preloading) to only pre-load certain features + + * 使用[自定义策略](#custom-preloading)来只预加载指定分区 + * choosing the "HTML5" or "hash" [URL style](#browser-url-styles) * 选择"HTML5"或"hash"[URL风格](#browser-url-styles) @@ -1089,13 +1097,10 @@ h3#router-directives 路由器指令集 .file hero-list.component.ts .file main.ts .file node_modules ... - .file typings ... .file index.html .file package.json .file styles.css .file tsconfig.json - .file typings.json - :marked Here are the files discussed in this milestone @@ -1210,7 +1215,7 @@ a#why-routing-module ### 你需要**路由模块**吗? - The _Routing Module_ *replaces* the routing configuration in the root or feature module. + The _Routing Module_ *replaces* the routing configuration in the root or feature module. _Either_ configure routes in the Routing Module _or_ within the module itself but not in both. **路由模块**在根模块或者特征模块替换了路由配置。在路由模块或者在模块内部配置路由,但不要同时在两处都配置。 @@ -2082,11 +2087,12 @@ h3#route-animation 为路由组件添加动画 :marked Next, we'll use a **host binding** for route animations named *@routeAnimation*. There is nothing special about the choice of the binding name, but since we are controlling route animation, we'll go with `routeAnimation`. - The binding value is set to `true` because we only care about the `*` and `void` states which are - [entering and leaving](../guide/animations.html#example-entering-and-leaving) animation states. + The binding value is set to `true` because we only care about the `:enter` and `:leave` states which are + [entering and leaving](../api/core/index/transition-function.html#transition-aliases-enter-and-leave-) transition aliases. 接下来,我们将对名叫`@routeAnimation`的路由动画使用**宿主绑定(HostBinding)**。选择绑定名时没什么特别的要求,但是由于我们是在控制路由的动画,所以把它叫做`routeAnimation`。 - 该绑定值被设置为`true`,因为我们只关心`*`和`void`状态,这些动画状态代表[进场和离开](../guide/animations.html#example-entering-and-leaving)。 + 该绑定值被设置为`true`,因为我们只关心`:enter`和`:leave`状态,这些动画状态代表[进场和离开](../api/core/index/transition-function.html#transition-aliases-enter-and-leave-)。 + We'll also add some display and positioning bindings for styling. @@ -2097,10 +2103,14 @@ h3#route-animation 为路由组件添加动画 :marked Now we can build our animation trigger, which we'll call *routeAnimation* to match the binding we previously setup. We'll use the **wildcard state** that matches any animation state our route component is in, along with - two *transitions*. One transition animates the component as it enters the application view (`void => *`), while the other - animates the component as it leaves the application view (`* => void`). + two *transitions*. One transition animates the component as it enters the application view (`:enter`), while the other + animates the component as it leaves the application view (`:leave`). + + 现在,我们可以构建动画触发器了,我们称之为*routeAnimation*来匹配我们以前定义的绑定。 + 我们的使用**通配符状态**,它们匹配我们这个路由组件的任意动画状态, + 后面是两个*转场动画*。一个转场动画(`:enter`)在组件进入应用视图时触发, + 另一个(`:leave`)在离开时触发。 - 现在,我们可以构建动画触发器了,我们称之为*routeAnimation*来匹配我们以前定义的绑定。我们的使用**通配符状态**,它们匹配我们这个路由组件的任意动画状态,后面是两个*转场动画*。一个转场动画(`void => *`)在组件进入应用视图时触发,另一个(`* => void`)在离开时触发。 We could add different transitions to different route components depending on our needs. We'll just animate our `HeroDetailComponent` for this milestone. @@ -2149,7 +2159,7 @@ h3#merge-hero-routes 把hero模块导入到AppModule中 我们导入了`HeroesModule`,并把它加入了`AppModule`的`imports`中。 We removed the `HeroListComponent` from the `AppModule`'s `declarations` because its being provided by the `HeroesModule` - now. This is important because their can be only **one** owner for a declared component. In our case, the `Heroes` module is + now. This is important because there can be only **one** owner for a declared component. In our case, the `Heroes` module is the owner of the `Heroes` components and is making them available to the `AppModule`. 我们从`AppModule`的`declarations`中移除了`HeroListComponent`,因为它现在改有`HeroesModule`提供了。 @@ -2234,13 +2244,10 @@ h3#merge-hero-routes 把hero模块导入到AppModule中 .file crisis-list.component.ts .file main.ts .file node_modules ... - .file typings ... .file index.html .file package.json .file styles.css .file tsconfig.json - .file typings.json - :marked @@ -3333,9 +3340,9 @@ h3#resolve-guard 解析: 提前获取组件数据 我们需要`Resolve`守卫。 - ### Preload route information + ### Fetch data before navigating - ### 预先加载路由信息 + ### 导航前预先加载路由信息 We'll update our `Crisis Detail` route to resolve our Crisis before loading the route, or if the user happens to navigate to an invalid crisis center `:id`, we'll navigate back to our list of existing crises. @@ -3387,7 +3394,7 @@ h3#resolve-guard 解析: 提前获取组件数据 接下来,将`CrisisDetailResolve`服务添加到危机中心路由模块的`providers`数组中,这样`Router`在路由过程中可以使用它。 -+makeExcerpt('app/crisis-center/crisis-center-routing.module.ts (resolve)', 'crisis-detail-resolve') ++makeExcerpt('app/crisis-center/crisis-center-routing.module.4.ts (resolve)', 'crisis-detail-resolve') :marked Now that we've added our `Resolve` guard to fetch data before the route loads, we no longer need to do this once we get into our `CrisisDetailComponent`. @@ -3425,7 +3432,7 @@ h3#resolve-guard 解析: 提前获取组件数据 `router/ts/app/app.component.ts, router/ts/app/crisis-center/crisis-center-home.component.ts, router/ts/app/crisis-center/crisis-center.component.ts, - router/ts/app/crisis-center/crisis-center-routing.module.ts, + router/ts/app/crisis-center/crisis-center-routing.module.4.ts, router/ts/app/crisis-center/crisis-list.component.ts, router/ts/app/crisis-center/crisis-detail.component.ts, router/ts/app/crisis-center/crisis-detail-resolve.service.ts, @@ -3501,7 +3508,7 @@ a#fragment 由于要在登录后导航到*危机管理*特征区的路由,所以我们还得更新它,来处理这些全局查询参数和片段。 -+makeExcerpt('app/admin/admin-dashboard.component.ts (v2)', '') ++makeExcerpt('app/admin/admin-dashboard.component.2.ts (v2)', '') :marked *Query Parameters* and *Fragments* are also available through the `ActivatedRoute` service available to route components. @@ -3596,7 +3603,7 @@ a#fragment 接下来,在`admin.routing.ts`中,把`admin`的**path**更改为空路径。路由器支持**空路径**路由,它可以在不必把别的路径添加到URL中的情况下,将多个路由组合到一起。用户还是可以访问`/crisis-center`,`CrisisCenterComponent`组件还是包含了子级路由的**路由组件**。 +makeTabs( - `router/ts/app/app-routing.module.ts, + `router/ts/app/app-routing.module.5.ts, router/ts/app/admin/admin-routing.module.ts`, 'lazy-load-admin,', `app-routing.module.ts (load children), @@ -3637,8 +3644,8 @@ a#fragment `imports` array since we'll be loading it on-demand an we'll remove the imported `AdminModule`. 我们构建了特性区,更新了路由配置来实现惰性加载,现在该做最后一步:将`AdminModule`分离到一个彻底独立的模块。因为现在按需加载`AdminModule`,所以在`app.module.ts`中,从`imports`数组中删除它。 - -+makeExcerpt('app/app.module.ts (async admin module)', '') + ++makeExcerpt('app/app.module.7.ts (async admin module)', '') h3#can-load-guard CanLoad Guard: guarding against loading of feature modules h3#can-load-guard CanLoad守卫: 保护特性模块的加载 @@ -3676,7 +3683,112 @@ h3#can-load-guard CanLoad守卫: 保护特性模块的加载 接下来,我们就把`AuthGuard`导入到`app.routing.ts`中,并把`AuthGuard`添加到`admin`路由的`canLoad`数组中。现在`admin`特性区就只有当获得访问授权时才会被加载了。 -+makeExcerpt('app/app-routing.module.ts (can load guard)', 'can-load-guard') ++makeExcerpt('app/app-routing.module.5.ts (can load guard)', 'can-load-guard') + +h3#preloading Pre-Loading: background loading of feature areas +:marked + We've learned how to load modules on-demand, but we can also take advantage of loading feature areas modules in *advance*. The *Router* + supports **pre-loading** of asynchronous feature areas prior to navigation to their respective URL. Pre-loading allows us to to load our initial route + quickly, while other feature modules are loaded in the background. Once we navigate to those areas, they will have already been loaded + as if they were included in our initial bundle. + + Each time a **successful** navigation happens, the *Router* will look through our configuration for lazy loaded feature areas + and react based on the provided strategy. + + The *Router* supports two pre-loading strategies by default: + + * No pre-loading at all which is the default. Lazy loaded feature areas are still loaded on demand. + * Pre-loading of all lazy loaded feature areas. + + The *Router* also supports [custom preloading strategies](#custom-preloading) for fine control over which modules to pre-load. + + We'll update our *CrisisCenterModule* to be loaded lazily by default and use the `PreloadAllModules` strategy + to load _all_ lazy loaded modules as soon as possible. + + +.l-sub-section + :marked + The **PreloadAllModules** strategy does not load feature areas protected by a [CanLoad](#can-load-guard) guard and this is by design. + The *CanLoad* guard blocks loading of feature module assets until authorized to do so. If you want to both preload a module and guard + against unauthorized access, use the [CanActivate](#can-activate-guard) guard instead. + +:marked + We'll update our route configuration to lazy load the *CrisisCenterModule*. We follow the same process as we did when we loaded the *AdminModule* asynchronously. + In the *crisis-center-routing.module.ts*, we'll change the *crisis-center* path to an *empty path* route. + + We'll move our redirect and *crisis-center* route to our `AppRoutingModule` routes and use the `loadChildren` string to load the *CrisisCenterModule*. + The redirect is also changed to load the `/heroes` route on initial load. + + Once we're finished, we'll remove the `CrisisCenterModule` from our `AppModule`'s imports. + + Here are the updated modules _before enabling preload_: + ++makeTabs( + `router/ts/app/app.module.ts, + router/ts/app/app-routing.module.6.ts, + router/ts/app/crisis-center/crisis-center-routing.module.ts + `, + ',preload-v1,', + `app.module.ts, + app-routing.module.ts, + crisis-center-routing.module.ts + `) + +:marked + The second argument in the `RouterModule.forRoot` method takes an object for additional configuration options. + We import the `PreloadAllModules` token from the router package and set the configuration option's `preloadingStrategy` property + with this `PreloadAllModules` token. + This tells the built-in *Router* pre-loader to immediately load **all** [unguarded](#preload-canload) feature areas that use `loadChildren`. + ++makeExcerpt('app/app-routing.module.6.ts (preload all)', '') + +:marked + Now when we visit `http://localhost:3000`, the `/heroes` route will load in the foreground, while the *CrisisCenterModule* and any other asynchronous feature + modules are _eagerly_ loaded in the background, waiting for us to navigate to them. + + +:marked + ### Custom Pre-Loading Strategy + + Pre-loading all modules works well in some situations, but in some cases we need more control over what gets loaded eagerly. This becomes more clear + as we load our application on a mobile device, or a low bandwidth connection. We may only want to preload certain feature modules based on user metrics + or other data points we gather over time. The *Router* lets us have more control with a **custom** preloading strategy. + + We can define our own strategy the same way the **PreloadAllModules** modules strategy was provided to our *RouterModule.forRoot* configuration object. + + Since we want to take advantage of this, we'll add a custom strategy that _only_ preloads the modules we select. We'll enable the preloading by using the *Route Data*, + which, as we learned, is an object to store arbitrary route data and and [resolve data](#resolve-guard). + + We'll add a custom `preload` boolean to our `crisis-center` route data that we'll use with our custom strategy. To see it in action, we'll add + the `route.path` to the `preloadedModules` array in our custom strategy service. We'll also log a message + to the console for the preloaded module. + ++makeExcerpt('app/app-routing.module.ts (route data preload)', 'preload-v2') + +:marked + To create our custom strategy we'll need to implement the abstract `PreloadingStrategy` class and the `preload` method. The `preload` method is called for each route + that loads its feature module asynchronously and determines whether to preload it. The `preload` method takes two arguments, the first being the `Route` that provides + the route configuration and a function that preloads the feature module. + + We'll name our strategy **PreloadSelectedModules** since we _only_ want to preload based on certain criteria. Our custom strategy looks for the **`preload`** boolean + value in our `Route Data` and if its true, it calls the `load` function provided by the built-in `Router` pre-loader that eagerly loads feature modules. + ++makeExcerpt('app/selective-preload-strategy.ts (preload selected modules)', '') + +:marked + In order to use our custom preloading strategy, we import it into our `app-routing.module.ts` and replace the `PreloadAllModules` strategy. We also add + the `PreloadSelectedModules` strategy to the `AppRoutingModule` providers array. This allows the *Router* pre-loader to inject our custom strategy. + + To confirm our *CrisisCenterModule* is being pre-loaded, we'll display our `preloadedModules` in the `Admin` dashboard. We already know how to use + an *ngFor* loop, so we'll skip over the details here. Since the `PreloadSelectedModules` is just a service, we can inject it into the `AdminDashboardComponent` + and wire it up to our list. + ++makeExcerpt('app/admin/admin-dashboard.component.ts (preloaded modules)', '') + +:marked + Once our application is loaded to our initial route, the *CrisisCenterModule* is loaded eagerly. We can verify this by logging in to the `Admin` feature area and + noting that the `crisis-center` is listed in the `Preloaded Modules` and logged to the console. We can continue to add feature modules to be selectively loaded eagerly. + @@ -3950,10 +4062,11 @@ code-example(format=".", language="bash"). :marked Learn about "providers" and the bootstrap process in the - [Dependency Injection chapter](dependency-injection#bootstrap) + [Dependency Injection chapter](dependency-injection.html#bootstrap) - 要学习关于“提供商”和启动过程的更多知识,参见[依赖注入](dependency-injection#bootstrap)一章。 + 要学习关于“提供商”和启动过程的更多知识,参见[依赖注入](dependency-injection.html#bootstrap)一章。 + :marked ### Which Strategy is Best? diff --git a/public/docs/ts/latest/guide/security.jade b/public/docs/ts/latest/guide/security.jade index 9928dd4dc1..1148fdce7e 100644 --- a/public/docs/ts/latest/guide/security.jade +++ b/public/docs/ts/latest/guide/security.jade @@ -344,59 +344,65 @@ h3#xsrf Cross-site request forgery h3#xsrf 跨站请求伪造(XSRF) :marked - In a cross-site request forgery, an attacker tricks the user into visiting a - _different_ page and has them, for example, submit a form that sends a request to your application's - web server. If the user is logged into your application, the browser will send authentication - cookies, and the attacker could—for example—cause a bank transfer in the user's name with - the right request. + In a cross-site request forgery (CSRF or XSRF), an attacker tricks the user into visiting + a different web page (e.g. `evil.com`) with malignant code that secretly sends a malicious request + to your application's web server (e.g. `example-bank.com`). + + Assume the user is logged into the application at `example-bank.com`. + The user opens an email and clicks a link to `evil.com` which opens in a new tab. + + The `evil.com` page immediately sends a malicious request to `example-bank.com`. + Perhaps it's a request to transfer money from the user's account to the attacker's account. + The browser automatically sends the `example-bank.com` cookies (including the authentication cookie) with this request. - 在跨站请求伪造(XSRF或CSFR)中,一个攻击者会欺骗用户,让它们访问_另一个_页面,并提交一个表单, - 向你应用程序的Web服务器发送一个请求。如果用户已经登录到你的应用程序,浏览器就会发送该用户的认证Cookie, - 这样攻击者就可以发送一个正确的请求,以该用户的名义发起一次银行转账。 + The `example-bank.com` server, if it lacks XSRF protection, can't tell the difference between a legitimate request from the application + and the forged request from `evil.com`. - To prevent this, your application must ensure that user requests originate in your own - application, not on a different site. A common technique is that the server sends a randomly - generated authentication token in a cookie, often with the name `XSRF-TOKEN`. Only the website - on which cookies are set can read the cookies, so only your own application can read this token. On - each API request, the server then validates the client by checking that the token is sent back, - usually in an HTTP header called `X-XSRF-TOKEN`. + + To prevent this, the application must ensure that a user request originates from the real + application, not from a different site. + The server and client must cooperate to thwart this attack. + + In a common anti-XSRF technique, the application server sends a randomly + generated authentication token in a cookie. + The client code reads the cookie and adds a custom request header with the token in all subsequent requests. + The server compares the received cookie value to the request header value and rejects the request if the values are missing or don't match. + + This technique is effective because all browsers implement the _same origin policy_. Only code from the website + on which cookies are set can read the cookies from that site and set custom headers on requests to that site. + That means only your application can read this cookie token and set the custom header. The malicious code on `evil.com` can't. - 为了防止这种情况,你必须确保每个用户的请求都是从你自己的应用中发出的,而不是从另一个网站发出的。 - 一个常见的技术是服务器随机生成一个用户认证令牌到cookie中,它的名字通常是`XSRF-TOKEN`。 - 由于Cookie只能被创建它的网站访问,所以你自己的程序能读取这个令牌,但攻击者不行。每收到一个API请求, - 服务器就会通过检查这个发回来的令牌对客户端进行验证,这个令牌通常放在HTTP头里,叫做`X-XSRF-TOKEN`。 + Angular's `http` has built-in support for the client-side half of this technique in its `XSRFStrategy`. + The default `CookieXSRFStrategy` is turned on automatically. + Before sending an HTTP request, the `CookieXSRFStrategy` looks for a cookie called `XSRF-TOKEN` and + sets a header named `X-XSRF-TOKEN` with the value of that cookie. + + The server must do its part by setting the + initial `XSRF-TOKEN` cookie and confirming that each subsequent state-modifying request + includes a matching `XSRF-TOKEN` cookie and `X-XSRF-TOKEN` header. - The Angular `http` client has built-in support for this technique. The default - `CookieXSRFStrategy` looks for a cookie called `XSRF-TOKEN` and sets an HTTP request header named - `X-XSRF-TOKEN` with the value of that cookie on every request. The server must set the - `XSRF-TOKEN` cookie and validate the response header for each state-modifying request. + XSRF/CSRF tokens should be unique per user and session, have a large random value generated by a + cryptographically secure random number generator, and should expire in a day or two. - Angular的`http`客户端具有对这项技术的内置支持。默认的`CookieXSRFStrategy`会寻找一个名叫`XSFR-TOKEN`的cookie。 - 在每个请求中,设置一个名为`X-XSRF-TOKEN`的HTTP请求头,并把该cookie的值赋给它。 - 服务器必须设置`XSRF-TOKEN` cookie,并为每个会修改状态的请求验证请求头。 - - CSRF tokens should be unique per user and session, have a large random value generated by a - cryptographically secure random number generator, and expire. - - CSRF令牌应该对每个用户和session是唯一的,它包含一大串由安全的随机数字生成器生成的随机值,并且会过期。 - - Angular applications can customize cookie and header names by binding their own - `CookieXSRFStrategy` value or implement an entirely custom `XSRFStrategy` through providing a custom - binding for that type by adding either of the following to your providers list: - - Angular应用程序可以通过绑定它们自己的`CookieXSRFStrategy`值来自定义cookie和HTTP头的名字, - 也可以通过提供一个自定义类型绑定来完全制定`XSRFStrategy`, - 只要把下列代码之一加到你的提供商列表里就可以了: + Your server may use a different cookie or header name for this purpose. + An Angular application can customize cookie and header names by providing its own `CookieXSRFStrategy` values. +code-example(language="typescript"). + { provide: XSRFStrategy, useValue: new CookieXSRFStrategy('myCookieName', 'My-Header-Name') } +:marked + Or you can implement and provide an entirely custom `XSRFStrategy`: code-example(language="typescript"). - { provide: XSRFStrategy, useValue: new CookieXSRFStrategy('myCookieName', 'My-Header-Name')} - { provide: XSRFStrategy, useClass: MyXSRFStrategy} + { provide: XSRFStrategy, useClass: MyXSRFStrategy } :marked - For information about CSRF at the Open Web Application Security Project (OWASP) see - [Cross-Site Request Forgery (CSRF)](https://www.owasp.org/index.php/Cross-Site_Request_Forgery_%28CSRF%29) and - [Cross-Site Request Forgery (CSRF) Prevention Cheat Sheet](https://www.owasp.org/index.php/CSRF_Prevention_Cheat_Sheet). The Stanford University - paper [Robust Defenses for Cross-Site Request Forgery](https://seclab.stanford.edu/websec/csrf/csrf.pdf) is also a rich source of detail. + For information about CSRF at the Open Web Application Security Project (OWASP), see + Cross-Site Request Forgery (CSRF) and + Cross-Site Request Forgery (CSRF) Prevention Cheat Sheet. + The Stanford University paper + Robust Defenses for Cross-Site Request Forgery is a rich source of detail. + + See also Dave Smith's easy-to-understand + talk on XSRF at AngularConnect 2016. 到开放式Web应用程序安全项目(OWASP)的[这里](https://www.owasp.org/index.php/Cross-Site_Request_Forgery_%28CSRF%29) 和[这里](https://www.owasp.org/index.php/CSRF_Prevention_Cheat_Sheet)学习更多关于跨站请求伪造(XSRF)的知识。 diff --git a/public/docs/ts/latest/guide/template-syntax.jade b/public/docs/ts/latest/guide/template-syntax.jade index 57e5176f6e..9a6d1601df 100644 --- a/public/docs/ts/latest/guide/template-syntax.jade +++ b/public/docs/ts/latest/guide/template-syntax.jade @@ -36,6 +36,8 @@ block includes * [HTML属性、class和style绑定](#other-bindings) * [Event binding](#event-binding) * [事件绑定](#event-binding) + * [Two-way data binding](#two-way) + * [双向数据绑定](#two-way) * [Two-way data binding with `NgModel`](#ngModel) * [使用`NgModel`进行双向数据绑定](#ngModel) * [Built-in directives](#directives) @@ -1412,28 +1414,64 @@ block style-property-name-dart-diff and the outer `
`, causing a double save. +makeExample('template-syntax/ts/app/app.component.html', 'event-binding-propagation')(format=".") - +#two-way +.l-main-section +:marked + ## Two-way binding + We often want to both display a data property and update that property when the user makes changes. + + On the element side that takes a combination of setting a specific element property + and listening for an element change event. + + Angular offers a special _two-way data binding_ syntax for this purpose, **`[(x)]`**. + The `[(x)]` syntax combines the brackets + of _Property Binding_, `[x]`, with the parentheses of _Event Binding_, `(x)`. +.callout.is-important + header [( )] = banana in a box + header [( )] = 盒子里的香蕉 + :marked + Visualize a *banana in a box* to remember that the parentheses go _inside_ the brackets. +:marked + The `[(x)]` syntax is easy to demonstrate when the element has a settable property called `x` + and a corresponding event named `xChange`. + Here's a `SizerComponent` that fits the pattern. + It has a `size` value property and a companion `sizeChange` event: ++makeExample('template-syntax/ts/app/sizer.component.ts', null, 'app/sizer.component.ts') +:marked + The initial `size` is an input value from a property binding. + Clicking the buttons increases or decreases the `size`, within min/max values constraints, + and then raises (_emits_) the `sizeChange` event with the adjusted size. + + Here's an example in which the `AppComponent.fontSize` is two-way bound to the `SizerComponent`: ++makeExample('template-syntax/ts/app/app.component.html', 'two-way-1')(format=".") +:marked + The `AppComponent.fontSize` establishes the initial `SizerComponent.size` value. + Clicking the buttons updates the `AppComponent.fontSize` via the two-way binding. + The revised `AppComponent.fontSize` value flows through to the _style_ binding, making the displayed text bigger or smaller. + Try it in the live example. + + The two-way binding syntax is really just syntactic sugar for a _property_ binding and an _event_ binding. + Angular _desugars_ the `SizerComponent` binding into this: ++makeExample('template-syntax/ts/app/app.component.html', 'two-way-2')(format=".") +:marked + The `$event` variable contains the payload of the `SizerComponent.sizeChange` event. + Angular assigns the `$event` value to the `AppComponent.fontSize` when the user clicks the buttons. + + Clearly the two-way binding syntax is a great convenience compared to separate property and event bindings. + + We'd like to use two-way binding with HTML form elements like `` and `` element's `value` property and `input` event. - - 通过分别绑定到``元素的`value`属性和`input`事件,我们能达到同样的效果。 +makeExample('template-syntax/ts/app/app.component.html', 'without-NgModel')(format=".") :marked - That’s cumbersome. Who can remember which element property to set and what event reports user changes? + That’s cumbersome. Who can remember which element property to set and which element event emits user changes? How do we extract the currently displayed text from the input box so we can update the data property? Who wants to look that up each time? @@ -1478,52 +1513,39 @@ block style-property-name-dart-diff +makeExample('template-syntax/ts/app/app.component.html', 'NgModel-3')(format=".") .l-sub-section :marked - The `ngModel` input property sets the element's value property and the `ngModelChange` output property + The `ngModel` data property sets the element's value property and the `ngModelChange` event property listens for changes to the element's value. - The details are specific to each kind of element and therefore the `NgModel` directive only works for elements, + + The details are specific to each kind of element and therefore the `NgModel` directive only works for specific form elements, such as the input text box, that are supported by a [ControlValueAccessor](../api/forms/index/ControlValueAccessor-interface.html). - We can't apply `[(ngModel)]` to our custom components until we write a suitable *value accessor*, + + We can't apply `[(ngModel)]` to a custom component until we write a suitable *value accessor*, a technique that is beyond the scope of this chapter. + That's something we might want to do for an Angular component or a WebComponent whose API we can't control. + + It's completely unnecessary for an Angular component that we _do_ control ... because we can name the value and event properties + to suit Angular's basic [two-way binding syntax](#two-way) and skip `NgModel` altogether. `ngModel`输入属性设置元素的值属性,而`ngModelChange`输出属性监听元素值的变化。 实现细节对每种元素都很特定,所以`NgModel`指令只和元素一起工作,比如输入框,它由[ControlValueAccessor](../api/common/index/ControlValueAccessor-interface.html)提供支持。 除非写一个合适的*值访问器*,否则我们不能把`[(ngModel)]`用在我们自己的自定义组件上。但*值访问器*技术超出了本章的范围。 :marked - Separate `ngModel` bindings is an improvement. We can do better. + Separate `ngModel` bindings is an improvement over binding to the element's native properties. We can do better. 把`ngModel`绑定分离开是一个提升,但我们还能做得更好。 We shouldn't have to mention the data property twice. Angular should be able to capture the component’s data property and set it - with a single declaration — which it can with the `[( )]` syntax: - - 我们不该两次引用这个数据属性。Angular应该能捕获组件的数据属性,并且把它设置为一个简单的定义 —— 那就用`[( )]`语法吧: + with a single declaration — which it can with the `[(ngModel)]` syntax: +makeExample('template-syntax/ts/app/app.component.html', 'NgModel-1')(format=".") - -.l-sub-section - :marked - `[(ngModel)]` is a specific example of a more general pattern in which Angular "de-sugars" the `[(x)]` syntax - into an `x` input property for property binding and an `xChange` output property for event binding. - Angular constructs the event property binding's template statement by appending `=$event` - to the literal string of the template expression. - - `[(ngModel)]`是一个更通用的模式中的具体例子,在这里,Angular会把`[(x)]`语法去掉语法糖,变成了一个供属性绑定用的输入属性`x`,和一个供事件绑定用的输出属性`xChange`。 - Angular通过在模板表达式的原始字符串后面追加上`=$event`,来构建出供事件绑定用的模板语句。 - - We can write a two-way binding directive of our own to exploit this behavior. - - 利用这一行为,我们也可以自己写出具有双向绑定功能的指令。 - - [(_x_)]="_e_" <==> [_x_]="_e_" (xChange)="_e_=$event" - :marked Is `[(ngModel)]` all we need? Is there ever a reason to fall back to its expanded form? `[(ngModel)]`就是我们所需的一切吗?有没有什么理由需要仰仗到它的展开形式? - The `[( )]` syntax can only _set_ a data-bound property. + The `[(ngModel)]` syntax can only _set_ a data-bound property. If we need to do something more or something different, we need to write the expanded form ourselves. - `[( )]`语法只能_设置_一个数据绑定属性。 + `[(ngModel)]`语法只能_设置_一个数据绑定属性。 如果需要做更多或不同的事情,我们得自己写它的展开形式。 Let's try something silly like forcing the input value to uppercase: @@ -2007,7 +2029,8 @@ block remember-the-brackets :marked ### Expanding `*ngSwitch` ### 展开`*ngSwitch` - A similar transformation applies to `*ngSwitch`. We can de-sugar the syntax ourselves. + + A similar transformation applies to `*ngSwitch`. We can unfold the syntax ourselves. Here's an example, first with `*ngSwitchCase` and `*ngSwitchDefault` and then again with `