fix: 精修翻译
This commit is contained in:
parent
56a017a977
commit
0d11c7d06b
|
@ -33,9 +33,9 @@ Even across a fast reliable network, round-trip delays can introduce significant
|
|||
|
||||
Angular applications, as single-page applications, are in a prime position to benefit from the advantages of service workers. Starting with version 5.0.0, Angular ships with a service worker implementation. Angular developers can take advantage of this service worker and benefit from the increased reliability and performance it provides, without needing to code against low-level APIs.
|
||||
|
||||
作为单页面应用,Angular 应用位于从 Service Worker 中受益的首要位置。
|
||||
作为单页面应用,Angular 应用可以受益于 Service Worker 的优势。
|
||||
从 Angular v5.0.0 开始,Angular 提供了一份 Service Worker 的实现。
|
||||
Angular 开发人员可以从这个 Service Worker 加强的可靠性和性能中获益,而不用再针对底层 API 写代码。
|
||||
Angular 开发人员可以利用 Service Worker,并受益于其增强的可靠性和性能,而无需再针对底层 API 写代码。
|
||||
|
||||
Angular's service worker is designed to optimize the end user experience of using an application over a slow or unreliable network connection, while also minimizing the risks of serving outdated content.
|
||||
|
||||
|
@ -103,7 +103,7 @@ For more information about browser support, see the [browser support](https://de
|
|||
|
||||
The remainder of this Angular documentation specifically addresses the Angular implementation of service workers.
|
||||
|
||||
本文档的其余部分会专注于讲 Angular 中的 Service Worker 实现。
|
||||
这份 Angular 文档的其它部分全都专注于讲 Angular 中的 Service Worker 实现。
|
||||
|
||||
## More on Angular service workers
|
||||
|
||||
|
|
|
@ -431,7 +431,7 @@ For real development, we strongly recommend [developing locally](guide/setup#dev
|
|||
|
||||
If you develop angular locally with `ng serve`, there will be `websocket` connection being setup automatically between browser and local dev server, so when your code change, browser can automatically refresh.
|
||||
|
||||
如果你使用 `ng serve` 进行本地开发,就会在浏览器和本地开发服务器之间自动建立一个 `WebSocket` 连接,因此,当你的代码变化时,浏览器也会自动刷新。
|
||||
如果你使用 `ng serve` 在本地进行 Angular 开发,就会在浏览器和本地开发服务器之间自动建立一个 `WebSocket` 连接,因此,当你的代码变化时,浏览器也会自动刷新。
|
||||
|
||||
In windows, by default one application can only have 6 websocket connections, <a href="https://msdn.microsoft.com/library/ee330736%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396#websocket_maxconn" title="MSDN WebSocket settings">MSDN WebSocket Settings</a>.
|
||||
So if IE was refreshed manunally or automatically by `ng serve`, sometimes, the websocket will not close properly, when websocket connections exceed limitations, `SecurityError` will be thrown, this error will not affect the angular application, you can just restart IE to clear this error, or modify the windows registry to update the limitations.
|
||||
|
|
|
@ -1302,7 +1302,6 @@ The following binding pairs do the same thing:
|
|||
_Interpolation_ is a convenient alternative to _property binding_ in many cases.
|
||||
|
||||
在多数情况下,插值表达式是更方便的备选项。
|
||||
实际上,在渲染视图之前,Angular 把这些插值表达式翻译成相应的属性绑定。
|
||||
|
||||
When rendering data values as strings, there is no technical reason to prefer one form to the other.
|
||||
You lean toward readability, which tends to favor interpolation.
|
||||
|
|
|
@ -11,7 +11,7 @@ This guide offers tips and techniques for unit and integration testing Angular a
|
|||
The guide presents tests of a sample application created with the [Angular CLI](cli). This sample application is much like the one created in the [_Tour of Heroes_ tutorial](tutorial).
|
||||
The sample application and all tests in this guide are available for inspection and experimentation:
|
||||
|
||||
该指南中的测试面向的是一个很像[《英雄指南》教程](tutorial)的 [Angular CLI](cli) 范例应用。
|
||||
该指南中的测试针对的是一个很像[《英雄指南》教程](tutorial)的 [Angular CLI](cli) 范例应用。
|
||||
这个范例应用及其所有测试都可以在下面的链接中进行查看和试用:
|
||||
|
||||
- <live-example embedded-style>Sample app</live-example>
|
||||
|
|
|
@ -335,7 +335,7 @@ export class AppModule {}
|
|||
|
||||
Create a module named `AppServerModule` to act as the root module when running on the server. This example places it alongside `app.module.ts` in a file named `app.server.module.ts`. The new module imports everything from the root `AppModule`, and adds `ServerModule`. It also adds `ModuleMapLoaderModule` to help make lazy-loaded routes possible during server-side renders with the Angular CLI.
|
||||
|
||||
在服务器上运行时,要创建一个名叫 `AppServerModule` 的模块作为根模块。这个例子中把它放在了 `app.module.ts` 附近的 `app.server.module.ts` 文件中。这个新模块从 `AppModule` 中导入了所有东西,并且导入了 `ServerModule`。它还导入了 `ModuleMapLoaderModule` 以帮助在服务端渲染时也能使用惰性加载路由。
|
||||
在服务器上运行时,要创建一个名叫 `AppServerModule` 的模块作为根模块。这个例子中把它放在了 `app.module.ts` 附近的 `app.server.module.ts` 文件中。这个新模块从 `AppModule` 中导入了所有东西,并且导入了 `ServerModule`。它还添加了 `ModuleMapLoaderModule` 以便在通过 Angular CLI 进行服务端渲染时也能使用惰性加载路由。
|
||||
|
||||
Here's an example in `src/app/app.server.module.ts`.
|
||||
|
||||
|
|
|
@ -409,6 +409,7 @@ See [Upgrading from AngularJS](guide/upgrade) to learn about:
|
|||
|
||||
`downgradeModule()` 和 `UpgradeModule` 之间的区别就是这些。
|
||||
其余的 `upgrade/static` API 和概念的工作方式在不同的混合式应用中都完全一样了。
|
||||
欲知详情,参见[从 AngularJS 升级](guide/upgrade)。
|
||||
|
||||
- [Using Angular Components from AngularJS Code](guide/upgrade#using-angular-components-from-angularjs-code).<br />
|
||||
_NOTE: If you are downgrading multiple modules, you need to specify the name of the downgraded
|
||||
|
@ -454,7 +455,7 @@ See [Upgrading from AngularJS](guide/upgrade) to learn about:
|
|||
is _not OK_ to use it in an AngularJS component that may be used independently of Angular or use
|
||||
it in a downgraded Angular component from a different module.
|
||||
|
||||
比如,在只使用 Angular 组件的升级过的组件中*可以*使用降级后的服务,但是,*不能*在那些不依赖 Angular 就能用的 AngularJS 组件中使用。
|
||||
比如,在只使用 Angular 组件的已升级组件中*可以*使用降级后的服务,但是,*不能*在那些不依赖 Angular 的 AngularJS 组件中使用它,也不能从其它模块中使用降级过的 Angular 组件。
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -494,7 +495,7 @@ angular.module('mainAngularJsModule', [
|
|||
|
||||
And that is all you need to do to get the full benefit of AOT for hybrid Angular apps.
|
||||
|
||||
这就是你想让混合式应用从 AOT 中受益时,所要做的一切。
|
||||
这就是当你想让混合式应用受益于 AOT 时所要做的一切。
|
||||
|
||||
## Conclusion
|
||||
|
||||
|
|
|
@ -317,7 +317,7 @@ exact [equivalents in Angular](guide/lifecycle-hooks), so organizing component l
|
|||
logic around them will ease the eventual Angular upgrade process.
|
||||
|
||||
控制器的生命周期钩子 `$onInit()`、`$onDestroy()` 和 `$onChanges()` 是 AngularJS 1.5 引入的另一些便利特性。
|
||||
它们都很像[Angular 中的等价物](guide/lifecycle-hooks),所以,围绕它们组织组件生命周期的逻辑会更容易升级。
|
||||
它们都很像[Angular 中的等价物](guide/lifecycle-hooks),所以,围绕它们组织组件生命周期的逻辑在升级到 Angular 时会更容易。
|
||||
|
||||
## Upgrading with ngUpgrade
|
||||
|
||||
|
@ -350,7 +350,7 @@ framework, and AngularJS code in the AngularJS framework. Both of these are the
|
|||
actual, fully featured versions of the frameworks. There is no emulation going on,
|
||||
so you can expect to have all the features and natural behavior of both frameworks.
|
||||
|
||||
当使用 `UpgradeModule` 时,你实际上在*同时运行两个版本的 Angular*。所有 Angular 的代码运行在 Angular 框架中,而 AngularJS 的代码运行在 AngularJS 框架中。所有这些都是真实的、全功能的框架版本。
|
||||
当使用 ngUpgrade 时,你实际上在*同时运行 AngularJS 和 Angular*。所有 Angular 的代码运行在 Angular 框架中,而 AngularJS 的代码运行在 AngularJS 框架中。所有这些都是真实的、全功能的框架版本。
|
||||
没有进行任何仿真,所以你可以认为同时存在着这两个框架的所有特性和自然行为。
|
||||
|
||||
What happens on top of this is that components and services managed by one
|
||||
|
@ -569,8 +569,9 @@ AngularJS and Angular approaches. Here's what happens:
|
|||
This is true whether the event originated in AngularJS or Angular code.
|
||||
The zone triggers Angular change detection after every event.
|
||||
|
||||
应用中发生的每件事都运行在 Angular 的 zone 里。
|
||||
应用中发生的每件事都运行在 Angular 的 zone 里。
|
||||
无论事件发生在 AngularJS 还是 Angular 的代码中,都是如此。
|
||||
这个 zone 会在每个事件之后触发 Angular 的变更检测。
|
||||
|
||||
* The `UpgradeModule` will invoke the AngularJS `$rootScope.$apply()` after
|
||||
every turn of the Angular zone. This also triggers AngularJS change
|
||||
|
@ -1075,11 +1076,10 @@ observing the following rules:
|
|||
<td>
|
||||
|
||||
As a two-way binding: `<my-component [(myValue)]="anExpression">`.
|
||||
Since most AngularJS two-way bindings actually only need a one-way binding
|
||||
in practice, `<my-component [myValue]="anExpression">` is often enough.
|
||||
Since most AngularJS two-way bindings actually only need a one-way binding in practice, `<my-component [myValue]="anExpression">` is often enough.
|
||||
|
||||
用作输入:`<my-component [myValue]="anExpression">` 或
|
||||
用作双向绑定:`<my-component [(myValue)]="anExpression"`
|
||||
用作双向绑定:`<my-component [(myValue)]="anExpression">`。
|
||||
由于大多数 AngularJS 的双向绑定实际上只是单向绑定,因此通常写成 `<my-component [myValue]="anExpression">` 也够用了。
|
||||
|
||||
</td>
|
||||
|
||||
|
@ -1203,8 +1203,8 @@ code. For example, you might have a service called `HeroesService` in AngularJS:
|
|||
You can upgrade the service using a Angular [factory provider](guide/dependency-injection-providers#factory-providers)
|
||||
that requests the service from the AngularJS `$injector`.
|
||||
|
||||
你可以 Angular 的[工厂提供商](guide/dependency-injection-providers#factory-providers)升级该服务,
|
||||
它从 AngularJS 的 `$injector` 请求服务。Angular 依赖的名称由你确定:
|
||||
你可以用 Angular 的[工厂提供商](guide/dependency-injection-providers#factory-providers)升级该服务,
|
||||
它从 AngularJS 的 `$injector` 请求服务。
|
||||
|
||||
Many developers prefer to declare the factory provider in a separate `ajs-upgraded-providers.ts` file
|
||||
so that they are all together, making it easier to reference them, create new ones and
|
||||
|
@ -1240,7 +1240,7 @@ You can then provide the service to Angular by adding it to the `@NgModule`:
|
|||
|
||||
Then use the service inside your component by injecting it in the component constructor using its class as a type annotation:
|
||||
|
||||
然后你就可以用它的类作为类型注解把它在 Angular 中进行注入了:
|
||||
然后在组件的构造函数中使用该服务的类名作为类型注解注入到组件中,从而在组件中使用它:
|
||||
|
||||
<code-example path="upgrade-module/src/app/ajs-to-a-providers/hero-detail.component.ts" header="hero-detail.component.ts">
|
||||
</code-example>
|
||||
|
@ -1632,8 +1632,8 @@ component API and the organization follows the
|
|||
which is an important [preparation step](guide/upgrade#follow-the-angular-styleguide) before
|
||||
a successful upgrade.
|
||||
|
||||
这确实是一个很好地起点。特别是,该结构遵循了[AngularJS 风格指南](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md),
|
||||
要想成功升级,这是一个很重要的[准备步骤](guide/upgrade#follow-the-angular-styleguide)。
|
||||
这确实是一个很好地起点。这些代码使用了 AngularJS 1.5 的组件 API,并遵循了 [AngularJS 风格指南](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md)进行组织,
|
||||
在成功升级之前,这是一个很重要的[准备步骤](guide/upgrade#follow-the-angular-styleguide)。
|
||||
|
||||
* Each component, service, and filter is in its own source file, as per the
|
||||
[Rule of 1](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#single-responsibility).
|
||||
|
@ -2020,7 +2020,7 @@ attached to the `<html>` element of the host page. This will no longer work in t
|
|||
app. Switch to the [ngUpgrade bootstrap](#bootstrapping-hybrid-applications) method
|
||||
instead.
|
||||
|
||||
本应用现在是使用宿主页面中附加到 `<html>` 元素上的 `ng-app` 指令引导的。
|
||||
本应用现在是使用宿主页面中附加到 `<html>` 元素上的 AngularJS 指令 `ng-app` 引导的。
|
||||
但在混合式应用中,不能再这么用了。你得用[ngUpgrade bootstrap](#bootstrapping-hybrid-applications)方法代替。
|
||||
|
||||
First, remove the `ng-app` attribute from `index.html`.
|
||||
|
@ -2183,8 +2183,8 @@ Here's the full, final code for the service:
|
|||
Notice that you're importing the `map` operator of the RxJS `Observable` separately.
|
||||
Do this for every RxJS operator.
|
||||
|
||||
注意,你单独导入了 RxJS `Observable` 中的 `map` 操作符。
|
||||
你需要对想用的所有 RxJS 操作符这么做,因为 Angular 默认不会加载所有 RxJS 操作符。
|
||||
注意,你要单独导入了 RxJS `Observable` 中的 `map` 操作符。
|
||||
对每个 RxJS 操作符都要这么做。
|
||||
|
||||
The new `Phone` service has the same features as the original, `ngResource`-based service.
|
||||
Because it's an Angular service, you register it with the `NgModule` providers:
|
||||
|
@ -2479,7 +2479,7 @@ as shown in [the Ahead-of-time Compilation chapter](guide/aot-compiler).
|
|||
Then change `main-aot.ts` to bootstrap the `AppComponentFactory` that was generated
|
||||
by the AOT compiler:
|
||||
|
||||
然后修改 `main-aot.ts` 的引导代码,通过所生成的 `AppComponentFactory` 来引导 AngularJS 应用:
|
||||
然后修改 `main-aot.ts` 的引导代码,来引导 AOT 编译器所生成的 `AppComponentFactory`:
|
||||
|
||||
<code-example path="upgrade-phonecat-2-hybrid/app/main-aot.ts" header="app/main-aot.ts">
|
||||
</code-example>
|
||||
|
@ -2542,10 +2542,10 @@ Create a new `app.component.ts` file with the following `AppComponent` class:
|
|||
<code-example path="upgrade-phonecat-3-final/app/app.component.ts" header="app/app.component.ts">
|
||||
</code-example>
|
||||
|
||||
It has a simple template that only includes the `<router-outlet>.
|
||||
It has a simple template that only includes the `<router-outlet>`.
|
||||
This component just renders the contents of the active route and nothing else.
|
||||
|
||||
它有一个很简单的模板,只包含 Angular 路由的 `<router-outlet>` 和 AngularJS 路由的 `ng-view` 指令。
|
||||
它有一个很简单的模板,只包含 Angular 路由的 `<router-outlet>`。
|
||||
该组件只负责渲染活动路由的内容,此外啥也不干。
|
||||
|
||||
The selector tells Angular to plug this root component into the `<phonecat-app>`
|
||||
|
@ -2773,7 +2773,7 @@ working. But when you change the bootstrap to that of a Hybrid app,
|
|||
you must make a few changes.
|
||||
|
||||
在转成 TypeScript 期间,你不用做什么就能让 E2E 测试正常工作。
|
||||
只有当你想做些修改而把组件及其模板升级到 Angular 时才需要做些处理。
|
||||
但是当你想改成按照混合式应用进行引导时,必须做一些修改。
|
||||
|
||||
Update the `protractor-conf.js` to sync with hybrid apps:
|
||||
|
||||
|
@ -2959,7 +2959,7 @@ service is no longer present after the upgrade, replace those calls with ones
|
|||
that use WebDriver's generic URL APIs instead. The first of these is
|
||||
the redirection spec:
|
||||
|
||||
同样,`PhoneCat` 的测试代码中有两个 Protractor API 调用内部使用了 `$location`。该服务没有了,
|
||||
同样,`PhoneCat` 的测试代码中有两个 Protractor API 调用内部使用了 AngularJS 的 `$location`。该服务没有了,
|
||||
你就得把这些调用用一个 WebDriver 的通用 URL API 代替。第一个 API 是“重定向(redirect)”规约:
|
||||
|
||||
<code-example path="upgrade-phonecat-3-final/e2e-spec.ts" region="redirect" header="e2e-tests/scenarios.ts">
|
||||
|
|
|
@ -144,11 +144,11 @@ restart it to make sure everything is clean.
|
|||
|
||||
<h2 id='download'>Step 1: Download the Angular Getting Started app</h2>
|
||||
|
||||
<h2 id='download'>第一步: 现在“快速上手”文件</h2>
|
||||
<h2 id='download'>第一步: 下载“ Angular 快速上手”文件</h2>
|
||||
|
||||
Go to the final code review in [Getting Started](guide/quickstart) and download the solution app project. These files contain a starter Angular app.
|
||||
|
||||
从 GitHub[下载“快速上手”的源代码](https://github.com/angular/quickstart)。如果下载的是一个压缩的 zip 文件,解压它。
|
||||
到 [Getting Started](guide/quickstart) 中查看最终代码,并下载这个解决方案的应用项目。这些文件包含一个起步级 Angular 应用。
|
||||
|
||||
<h2 id='create-project'>Step 2: Create the Visual Studio ASP.NET project</h2>
|
||||
|
||||
|
|
|
@ -140,11 +140,12 @@ export interface Directive {
|
|||
* Angular only allows directives to apply on CSS selectors that do not cross
|
||||
* element boundaries.
|
||||
*
|
||||
* Angular 的指令只允许那些不跨元素边界的 CSS 选择器。
|
||||
*
|
||||
* For the following template HTML, a directive with an `input[type=text]` selector,
|
||||
* would be instantiated only on the `<input type="text">` element.
|
||||
*
|
||||
* Angular 的指令只允许那些不跨元素边界的 CSS 选择器。比如,考虑一个带有 `input[type=text]` 选择器的指令。
|
||||
* 对于下列 HTML,该指令只会在 `<input type="text">` 元素上实例化。
|
||||
* 对于下列模板 HTML,带有 `input[type=text]` 选择器的指令只会在 `<input type="text">` 元素上实例化。
|
||||
*
|
||||
* ```html
|
||||
* <form>
|
||||
|
@ -643,7 +644,7 @@ export interface Component extends Directive {
|
|||
* The URL of a template file for an Angular component. If provided,
|
||||
* do not supply an inline template using `template`.
|
||||
*
|
||||
* 组件模板文件的 URL。如果提供了它,就不要再用 `template` 来提供内联模板了。
|
||||
* Angular 组件模板文件的 URL。如果提供了它,就不要再用 `template` 来提供内联模板了。
|
||||
*/
|
||||
templateUrl?: string;
|
||||
|
||||
|
@ -651,7 +652,7 @@ export interface Component extends Directive {
|
|||
* An inline template for an Angular component. If provided,
|
||||
* do not supply a template file using `templateUrl`.
|
||||
*
|
||||
* 组件的内联模板。如果提供了它,就不要再用 `templateUrl` 提供模板了。
|
||||
* Angular 组件的内联模板。如果提供了它,就不要再用 `templateUrl` 提供模板了。
|
||||
*/
|
||||
template?: string;
|
||||
|
||||
|
|
|
@ -106,8 +106,7 @@ export interface SafeResourceUrl extends SafeValue {}
|
|||
* into this call. Make sure any user data is appropriately escaped for this security context.
|
||||
* For more detail, see the [Security Guide](http://g.co/ng/security).
|
||||
*
|
||||
*
|
||||
* 调用任何 `bypassSecurityTrust...` API 都会禁用 Anuglar 对传入的值的内置净化机制。
|
||||
* 调用任何 `bypassSecurityTrust...` API 都会禁用 Angular 对传入的值的内置净化机制。
|
||||
* 要小心翼翼的检查和审计所有的值和到该调用的代码执行路径。
|
||||
* 要确保任何一个用户数据都针对这个安全上下文进行过适当的转义(escape)。
|
||||
* 欲知详情,参见[安全](http://g.co/ng/security)。
|
||||
|
|
Loading…
Reference in New Issue