`
+})
+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 `