From 89060a39df56d870eb5d2190ac2e76fc5479e827 Mon Sep 17 00:00:00 2001 From: Zhicheng Wang Date: Wed, 28 Feb 2018 13:43:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=8D=E6=AD=A3=E5=B8=B8=E7=9A=84?= =?UTF-8?q?=E4=B8=AD=E8=8B=B1=E6=96=87=E6=AE=B5=E8=90=BD=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aio/content/guide/architecture.md | 16 +++++++++++++--- aio/content/guide/change-log.md | 19 +++++++++++++------ aio/content/guide/dependency-injection.md | 5 +++-- aio/content/guide/deployment.md | 14 +++++++++----- aio/content/guide/forms.md | 2 +- aio/content/guide/glossary.md | 8 ++++++-- aio/content/guide/lifecycle-hooks.md | 2 +- aio/content/guide/router.md | 15 +++++++++++++-- aio/content/guide/security.md | 8 ++++++-- aio/content/guide/styleguide.md | 9 +++++++-- aio/content/guide/upgrade.md | 1 - aio/content/guide/webpack.md | 1 + 12 files changed, 73 insertions(+), 27 deletions(-) diff --git a/aio/content/guide/architecture.md b/aio/content/guide/architecture.md index fc60aa9b19..aa623b8cce 100644 --- a/aio/content/guide/architecture.md +++ b/aio/content/guide/architecture.md @@ -440,8 +440,12 @@ The template, metadata, and component together describe a view. 模板、元数据和组件共同描绘出这个视图。 Apply other metadata decorators in a similar fashion to guide Angular behavior. -`@Injectable`, `@Input`, and `@Output` are a few of the more popular decorators.其它元数据装饰器用类似的方式来指导 Angular 的行为。 -例如`@Injectable`、`@Input`和`@Output`等是一些最常用的装饰器。
+`@Injectable`, `@Input`, and `@Output` are a few of the more popular decorators. + +其它元数据装饰器用类似的方式来指导 Angular 的行为。 +例如`@Injectable`、`@Input`和`@Output`等是一些最常用的装饰器。 + +
The architectural takeaway is that you must add metadata to your code so that Angular knows what to do. @@ -470,7 +474,13 @@ a mechanism for coordinating parts of a template with parts of a component. Add binding markup to the template HTML to tell Angular how to connect both sides. Angular 支持**数据绑定**,一种让模板的各部分与组件的各部分相互合作的机制。 -我们往模板 HTML 中添加绑定标记,来告诉 Angular 如何把二者联系起来。As the diagram shows, there are four forms of data binding syntax. Each form has a direction — to the DOM, from the DOM, or in both directions.如图所示,数据绑定的语法有四种形式。每种形式都有一个方向 —— 绑定到 DOM 、绑定自 DOM 以及双向绑定。
+我们往模板 HTML 中添加绑定标记,来告诉 Angular 如何把二者联系起来。 + +As the diagram shows, there are four forms of data binding syntax. Each form has a direction — to the DOM, from the DOM, or in both directions. + +如图所示,数据绑定的语法有四种形式。每种形式都有一个方向 —— 绑定到 DOM 、绑定自 DOM 以及双向绑定。 + +
The `HeroListComponent` [example](guide/architecture#templates) template has three forms: diff --git a/aio/content/guide/change-log.md b/aio/content/guide/change-log.md index fa1497c134..e165529f0b 100644 --- a/aio/content/guide/change-log.md +++ b/aio/content/guide/change-log.md @@ -136,20 +136,27 @@ Revised samples are clearer and cover all topics discussed ## Miscellaneous (2017-01-05) -## 杂项 (2017-01-05)* [Setup](guide/setup) guide: -added (optional) instructions on how to remove _non-essential_ files. [环境搭建](guide/setup)指南: - 添加了(可选的)步骤说明,告诉你如何移除*非核心*文件。 +## 杂项 (2017-01-05) + +* [Setup](guide/setup) guide: + + [环境搭建](guide/setup)指南: + + added (optional) instructions on how to remove _non-essential_ files. + + 添加了(可选的)步骤说明,告诉你如何移除*非核心*文件。 + * No longer consolidate RxJS operator imports in `rxjs-extensions` file; each file should import what it needs. - 不再在`rxjs-extensions`文件中统一导入RxJS的操作符,每个文件应该各自导入它自己所需的。 + 不再在`rxjs-extensions`文件中统一导入RxJS的操作符,每个文件应该各自导入它自己所需的。 * All samples prepend template/style URLs with `./` as a best practice. - 所有范例都在模板/样式的URL之前添加`./`前缀 …… 而且你在实际开发中也应该这么做。 + 所有范例都在模板/样式的URL之前添加`./`前缀 …… 而且你在实际开发中也应该这么做。 * [Style Guide](guide/styleguide): copy edits and revised rules. - [风格指南](guide/styleguide):复制了编辑过的和修改过的规则。 + [风格指南](guide/styleguide):复制了编辑过的和修改过的规则。 ## Router: more detail (2016-12-21) diff --git a/aio/content/guide/dependency-injection.md b/aio/content/guide/dependency-injection.md index f22c65f6d5..e20a4206fe 100644 --- a/aio/content/guide/dependency-injection.md +++ b/aio/content/guide/dependency-injection.md @@ -1035,10 +1035,11 @@ you'll get a runtime null reference error. You actually can define the component first with the help of the `forwardRef()` method as explained in this [blog post](http://blog.thoughtram.io/angular/2015/09/03/forward-references-in-angular-2.html). -But it's best to avoid the problem altogether by defining components and services in separate files. - 在`forwardRef()`方法的帮助下,实际上也可以先定义组件, 具体说明见这篇[博客](http://blog.thoughtram.io/angular/2015/09/03/forward-references-in-angular-2.html)。 + +But it's best to avoid the problem altogether by defining components and services in separate files. + 但是为什么要先给自己找麻烦呢? 还是通过在独立的文件中定义组件和服务,完全避免此问题吧。 diff --git a/aio/content/guide/deployment.md b/aio/content/guide/deployment.md index a06e59ded5..ef24c71578 100644 --- a/aio/content/guide/deployment.md +++ b/aio/content/guide/deployment.md @@ -408,7 +408,8 @@ The list is by no means exhaustive, but should provide you with a good starting [rewrite rule](http://httpd.apache.org/docs/current/mod/mod_rewrite.html) to the `.htaccess` file as shown (https://ngmilk.rocks/2015/03/09/angularjs-html5-mode-or-pretty-urls-on-apache-using-htaccess/): -[Apache](https://httpd.apache.org/):在`.htaccess`文件中添加一个[重写规则](http://httpd.apache.org/docs/current/mod/mod_rewrite.html), + + [Apache](https://httpd.apache.org/):在`.htaccess`文件中添加一个[重写规则](http://httpd.apache.org/docs/current/mod/mod_rewrite.html), 代码如下([出处](https://ngmilk.rocks/2015/03/09/angularjs-html5-mode-or-pretty-urls-on-apache-using-htaccess/)): @@ -427,8 +428,9 @@ to the `.htaccess` file as shown [Front Controller Pattern Web Apps](https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#front-controller-pattern-web-apps), modified to serve `index.html`: + [NGinx](http://nginx.org/):使用`try_files`指向`index.html`,详细描述见[Web应用的前端控制器模式](https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#front-controller-pattern-web-apps)。 -[NGinx](http://nginx.org/):使用`try_files`指向`index.html`,详细描述见[Web应用的前端控制器模式](https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#front-controller-pattern-web-apps)。 + try_files $uri $uri/ /index.html; @@ -437,7 +439,9 @@ modified to serve `index.html`: * [IIS](https://www.iis.net/): add a rewrite rule to `web.config`, similar to the one shown [here](http://stackoverflow.com/a/26152011/2116927): -[IIS](https://www.iis.net/):往`web.config`中添加一条重写规则,类似于[这里](http://stackoverflow.com/a/26152011/2116927): + [IIS](https://www.iis.net/):往`web.config`中添加一条重写规则,类似于[这里](http://stackoverflow.com/a/26152011/2116927): + + <system.webServer> <rewrite> <rules> @@ -475,13 +479,13 @@ and to [rewrite rule](https://firebase.google.com/docs/hosting/url-redirects-rewrites#section-rewrites). -[Firebase主机服务](https://firebase.google.com/docs/hosting/):添加一条[重写规则](https://firebase.google.com/docs/hosting/url-redirects-rewrites#section-rewrites)。 + [Firebase主机服务](https://firebase.google.com/docs/hosting/):添加一条[重写规则](https://firebase.google.com/docs/hosting/url-redirects-rewrites#section-rewrites)。 "rewrites": [ { "source": "**", "destination": "/index.html" } ] - + {@a cors} diff --git a/aio/content/guide/forms.md b/aio/content/guide/forms.md index a78841c0ab..44e7704198 100644 --- a/aio/content/guide/forms.md +++ b/aio/content/guide/forms.md @@ -350,7 +350,7 @@ access to all of the template-driven forms features, including `ngModel`. If a component, directive, or pipe belongs to a module in the `imports` array, ​_don't_​ re-declare it in the `declarations` array. If you wrote it and it should belong to this module, ​_do_​ declare it in the `declarations` array. -如果某个组件、指令或管道是属于`imports`中所导入的某个模块的,那就_不能再_把它再声明到本模块的`declarations`数组中。 + 如果某个组件、指令或管道是属于`imports`中所导入的某个模块的,那就_不能再_把它再声明到本模块的`declarations`数组中。 如果它是你自己写的,并且确实属于当前模块,*才应该*把它声明在`declarations`数组中。 diff --git a/aio/content/guide/glossary.md b/aio/content/guide/glossary.md index d9903b7c90..ff20024f58 100644 --- a/aio/content/guide/glossary.md +++ b/aio/content/guide/glossary.md @@ -758,10 +758,14 @@ Angular has the following types of modules: Angular有下列模块类型: * [NgModules](guide/glossary#ngmodule). -For details and examples, see the [NgModules](guide/ngmodules) page.[Angular 模块](guide/glossary#ngmodule),见[Angular 模块](guide/ngmodule)。 +For details and examples, see the [NgModules](guide/ngmodules) page. + + [Angular 模块](guide/glossary#ngmodule),见[Angular 模块](guide/ngmodule)。 + * ES2015 modules, as described in this section. - + ES2015模块,如本节所述。 + diff --git a/aio/content/guide/lifecycle-hooks.md b/aio/content/guide/lifecycle-hooks.md index 0828986124..1d13be0cfb 100644 --- a/aio/content/guide/lifecycle-hooks.md +++ b/aio/content/guide/lifecycle-hooks.md @@ -614,7 +614,7 @@ Experienced developers agree that components should be cheap and safe to constru [explains why](http://misko.hevery.com/code-reviewers-guide/flaw-constructor-does-real-work/) you should avoid complex constructor logic. -Misko Hevery,Angular项目的头,在[这里解释](http://misko.hevery.com/code-reviewers-guide/flaw-constructor-does-real-work/)了你为什么应该避免复杂的构造函数逻辑。 + Misko Hevery,Angular项目的组长,在[这里解释](http://misko.hevery.com/code-reviewers-guide/flaw-constructor-does-real-work/)了你为什么应该避免复杂的构造函数逻辑。 diff --git a/aio/content/guide/router.md b/aio/content/guide/router.md index 2b6f1268a2..b77fc04c09 100644 --- a/aio/content/guide/router.md +++ b/aio/content/guide/router.md @@ -4171,7 +4171,12 @@ you should see something like the following URL in the browser address bar. The interesting part of the URL follows the `...`: -这个URL中有意思的部分是`...`后面的这些:* The `crisis-center` is the primary navigation. `crisis-center`是主导航。 +这个URL中有意思的部分是`...`后面的这些: + +* The `crisis-center` is the primary navigation. + + `crisis-center`是主导航。 + * Parentheses surround the secondary route. 圆括号包裹的部分是第二路由。 @@ -5820,7 +5825,13 @@ But first, make a few changes to the `AppRoutingModule`. 但是首先,要对`AppRoutingModule`做少量修改。 1. Import `SelectivePreloadingStrategy` into `AppRoutingModule`. -把`SelectivePreloadingStrategy`导入到`AppRoutingModule`中。1. Replace the `PreloadAllModules` strategy in the call to `forRoot` with this `SelectivePreloadingStrategy`. 把`PreloadAllModules`策略替换成对`forRoot`的调用,并且传入这个`SelectivePreloadingStrategy`。 + + 把`SelectivePreloadingStrategy`导入到`AppRoutingModule`中。 + +1. Replace the `PreloadAllModules` strategy in the call to `forRoot` with this `SelectivePreloadingStrategy`. + + 把`PreloadAllModules`策略替换成对`forRoot`的调用,并且传入这个`SelectivePreloadingStrategy`。 + 1. Add the `SelectivePreloadingStrategy` strategy to the `AppRoutingModule` providers array so it can be injected elsewhere in the app. diff --git a/aio/content/guide/security.md b/aio/content/guide/security.md index 1287f9772e..974c2f1b51 100644 --- a/aio/content/guide/security.md +++ b/aio/content/guide/security.md @@ -403,8 +403,12 @@ Perhaps it's a request to transfer money from the user's account to the attacker The browser automatically sends the `example-bank.com` cookies (including the authentication cookie) with this request. 该`evil.com`页面立刻发送恶意请求到`example-bank.com`。这个请求可能是从用户账户转账到攻击者的账户。 -与该请求一起,浏览器自动发出`example-bank.com`的cookie。If the `example-bank.com` server lacks XSRF protection, it can't tell the difference between a legitimate -request from the application and the forged request from `evil.com`.如果`example-bank.com`服务器缺乏XSRF保护,就无法辨识请求是从应用程序发来的合法请求还是从`evil.com`来的假请求。 +与该请求一起,浏览器自动发出`example-bank.com`的cookie。 + +If the `example-bank.com` server lacks XSRF protection, it can't tell the difference between a legitimate +request from the application and the forged request from `evil.com`. + +如果`example-bank.com`服务器缺乏XSRF保护,就无法辨识请求是从应用程序发来的合法请求还是从`evil.com`来的假请求。 To prevent this, the application must ensure that a user request originates from the real application, not from a different site. diff --git a/aio/content/guide/styleguide.md b/aio/content/guide/styleguide.md index f3f82446be..451bb28d84 100644 --- a/aio/content/guide/styleguide.md +++ b/aio/content/guide/styleguide.md @@ -3401,7 +3401,10 @@ and more difficult in a flat structure. @@ -5601,7 +5604,9 @@ Compare with the less preferred `host` metadata alternative. **Why?** When providing the service to a top level component, -that instance is shared and available to all child components of that top level component.**为何?**在顶层组件提供服务时,该服务实例在所有子组件中可见并共享。 +that instance is shared and available to all child components of that top level component. + +**为何?**在顶层组件提供服务时,该服务实例在所有子组件中可见并共享。 diff --git a/aio/content/guide/upgrade.md b/aio/content/guide/upgrade.md index 300b2dcacb..27fba1ee9c 100644 --- a/aio/content/guide/upgrade.md +++ b/aio/content/guide/upgrade.md @@ -2294,7 +2294,6 @@ Do that in a new file called `ajs-upgraded-providers.ts` and import it in `app.m 来把`$routeParams`包装成Angular的服务提供商。 新建一个名叫`ajs-upgraded-providers.ts`的文件,并且在`app.module.ts`中导入它: - diff --git a/aio/content/guide/webpack.md b/aio/content/guide/webpack.md index d4b9a6b48c..443c27f222 100644 --- a/aio/content/guide/webpack.md +++ b/aio/content/guide/webpack.md @@ -1138,6 +1138,7 @@ they're added behind the scenes by the `angular2-template-loader` plug-in. `vendor.ts`由`import`提供商依赖的语句组成,它最终决定了`vender.js`的内容。 本应用也导入这些模块,如果没有`CommonsChunkPlugin`插件检测出这种重叠,并且把它们从`app.js`中移除,它们就会同时出现在`app.js`包中。 + {@a conclusion} ## Conclusion