angular 4.0 文档记录 - Christian-Yang/Translate-and-save GitHub Wiki

原文被墙了,但是国内有人把这个文章引进来了,地址为:http://www.tuicool.com/articles/7jqIbuz
Angular version 4.0.0 - invisible-make over - is now available. This is a major release following our announced adoption of Semantic Versioning , and is backwards compatible with 2.x.x for most applications.
angular4.0.0版 - 隐形 - 结束 - 现在可用。 这是我们宣布采用语义版本控制后的主要版本,并且向大多数应用程序向后兼容2.x.x
We are very excited to share this release with the community, as it includes some major improvements and functionality that we have been working on for the past 3 months. We’ve worked hard to make sure that it’s easy for developers to update to this release.
我们很高兴与社区分享这个版本,因为它包括我们在过去3个月中一直在努力的一些重大改进和功能。 我们已经努力确保开发人员可以轻松更新此版本。
What’s New
Smaller & Faster
新特性是什么? 更小&更快 In this release we deliver on our promise to make Angular applications smaller and faster. By no mean are we done yet, and you'll see us being focused on making further improvements in the coming months.
在这个版本中,我们履行我们的承诺,使Angular应用程序更小更快。 这并不意味着我们已经完成,你会看到我们将重点放在未来几个月进一步改进【未来几个月还有重大的改进】。

View Engine
视图引擎
We’ve made changes under to hood to what AOT generated code looks like. These changes reduce the size of the generated code for your components by around 60% in most cases. The more complex your templates are, the higher the savings.
我们已经对AOT生成的代码看起来进行了更改。 在大多数情况下,这些更改会将生成的代码的大小减少约60%。 模板越复杂,节省越多。
During our release candidate period, we heard from many developers that migrating to 4 reduced their production bundles by hundreds of kilobytes.
在我们发布候选版本期间,我们从许多开发人员那里听到,迁移到angular 4个生产包的数量减少了几千千字节。
Read the Design Doc to learn more about what we did with the View Engine.
阅读设计文档,了解我们使用View Engine所做的更多信息。

Animation Package
动画包
We have pulled animations out of @angular/core and into their own package. This means that if you don’t use animations, this extra code will not end up in your production bundles.
我们已经将动画从@angular/core中拉回到自己的包中。 这意味着如果您不使用动画,这个额外的代码不会最终在您的生产包中。
This change also allows you to more easily find documentation and to take better advantage of autocompletion. You can add animations yourself to your main NgModule by importing BrowserAnimationsModule from @angular/platform-browser/animations .
此更改还允许您更轻松地查找文档,并更好地利用自动完成。 您可以通过从@angular/platform-browser/animations导入BrowserAnimationsModule,将自己的动画添加到您的主要NgModule中。

New Features
新特质 Improved *ngIf and ngFor
改进了
ngIf 和 *ngFor

Our template binding syntax now supports a couple helpful changes. You can now use an if/else style syntax, and assign local variables such as when unrolling an observable.
我们的模板绑定语法现在支持几个有用的更改。 现在可以使用if / else样式语法,并分配局部变量,例如在展开observable时。
< div * ngIf = "userList | async as users; else loading" > < user -profile * ngFor = "let user of users; count as count" [ user ]= "user" > </ user -profile > < div >{{count}} total users</ div > </ div > < ng -template # loading >Loading...</ ng -template >
Angular Universal
Angular通用
Universal, the project that allows developers to run Angular on a server, is now up to date with Angular again, and this is the first release since Univesal, originally a community-driven project, was adopted by the Angular team. This release now includes the results of the internal and external work from the Universal team over the last few months. The majority of the Universal code is now located in @angular/platform-server .
通用,允许开发人员在服务器上运行Angular的项目现在更新为Angular,这是Angular团队采用的Univesal(最初是社区驱动的项目)以来的第一个版本。 该版本现在包括过去几个月来自Universal团队的内部和外部工作的结果。 通用代码的大部分现在位于@ angular / platform-server中。
To learn more about taking advantage of Angular Universal, take a look the new renderModuleFactory method in @angular/platform-server , or Rob Wormald’s Demo Repository . More documentation and code samples are forthcoming.

要了解有关利用Angular Universal的更多信息,请查看@angular/platform-server或Rob Wormald的Demo Repository中的新的renderModuleFactory方法。 更多的文档和代码示例即将到来。

TypeScript 2.1 and 2.2 compatibility
TypeScript 2.1和2.2的兼容性
We’ve updated Angular to a more recent version of TypeScript. This will improve the speed of ngc and you will get better type checking throughout your application.
我们已将Angular更新为更新版本的TypeScript。 这将提高ngc的速度,您将在整个应用程序中获得更好的类型检查。
Source Maps for Templates
模板源映射
Now when there is an error caused by something in one of your templates, we generate source maps that give a meaningful context in terms of the original template.
现在,当您的一个模板中的某些内容发生错误时,我们会生成源映射,从而为原始模板提供有意义的上下文。
Packaging Changes
打包变更
Flat ES Modules (Flat ESM / FESM)
扁平ES模块(扁平ESM / FESM)
We now ship flattened versions of our modules ("rolled up" version of our code in the EcmaScript Module format, see example file ). This format should help tree-shaking, help reduce the size of your generated bundles, and speed up build, transpilation, and loading in the browser in certain scenarios.
我们现在将我们的模块的扁平化版本(“rollup”版本的代码以EcmaScript模块格式发布),请参阅示例文件)。 这种格式应该有助于 tree-shaking树状摇晃,有助于减少生成的包的大小,并在某些情况下加快浏览器的构建,扩展和加载。
Read more about the importance of Flat ES Modules in "The cost of small modules"
阅读更多关于Flat ES模块在“小模块成本”中的重要性

Experimental ES2015 Builds
实验ES2015构建
We now also ship our packages in the ES2015 Flat ESM format. This option is experimental and opt-in. Developers have reported up to 7% bundle size savings when combining these packages with Rollup. To try out these new packages, configure your build toolchain to resolve "es2015" property in package.json over the regular "module" property .
我们现在还以ES2015 Flat ESM格式发货。 此选项是实验性的并选择加入。 当将这些软件包与Rollup组合时,开发人员已经报告了节省了高达7%的捆绑包大小。 要尝试这些新软件包,请配置您的构建工具链,以通过常规“module”属性解析package.json中的“es2015”属性。
Experimental Closure Compatibility
实验闭合兼容性
All of our code now has Closure annotations, making it possible to take advantage of advanced Closure optimizations, resulting in smaller bundle sizes and better tree shaking.
我们所有的代码现在都具有Closure注释,可以利用高级Closure优化,从而减少捆绑包的大小和更好的树状抖动。

Updating to 4.0.0

Updating to 4 is as easy as updating your Angular dependencies to the latest version, and double checking if you want animations. This will work for most use cases. 更新到4与更新您的Angular依赖关系到最新版本一样简单,并重新检查是否需要动画。 这将适用于大多数用例。

linux下升级:
On Linux/Mac:
npm install @angular/{common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router,animations}@latest typescript@latest --save
windows下升级:
On Windows:
npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest typescript@latest -- save
Then run whatever ng serve or npm start command you normally use, and everything should work.
然后运行您正常使用的任何ng服务或npm启动命令,一切都应该起作用。
If you rely on Animations, import the new BrowserAnimationsModule from @angular/platform-browser/animations in your root NgModule. Without this, your code will compile and run, but animations will trigger an error. Imports from @angular/core were deprecated, use imports from the new package import { trigger, state, style, transition, animate } from '@angular/animations'; .
如果您依靠动画,请从您的根NgModule中的@ angular / platform-browser / animations导入新的BrowserAnimationsModule。 没有这个,您的代码将编译并运行,但动画将触发错误。 来自@ angular / core的导入已被弃用,使用从“@ angular / animations”导入新包import {trigger,state,style,transition,animate}; 。
We are beginning work on an interactive Angular Update Guide if you would like to see more information about making any needed changes to your application.
如果您想查看有关对应用程序进行任何必要更改的更多信息,我们将开始使用交互式angular更新指南。
Known Issues
已知的问题
One of the goals for version 4 was to make Angular compatible with TypeScript's strictNullChecks setting, allowing for a more restrictive subset of types to be mandated. We discovered during the RC period that there is more work to be done for this to function properly in all use cases, so we intentionally made 4.0 incompatible with the strictNullChecks setting in order to avoid breaking apps that would otherwise eagerly adopt this TypeScript mode when the proper support lands in 4.1 (tracking issue is #15432 ).
版本4的目标之一是使Angular与TypeScript的strictNullChecks设置兼容,允许强制更多限制类型的子集。 我们在RC期间发现,在所有用例中,为了正常运行,需要做更多的工作才能正常工作,所以我们有意制作了4.0与strictNullChecks设置不兼容的方法,以避免打破其他方式热门采用此TypeScript模式的应用程序 适当的支持位于4.1(跟踪问题是#15432)。
What's next?
下一步是什么? We are in the process of setting the roadmap for the next 6 months, following the same cadence as our published release schedule for 2.x. You'll see patch updates to 4.0.0 and we are already getting started on 4.1. We are going to continue making Angular smaller and faster, and we're going to evolve capabilities such @angular/http , @angular/service-worker , and @angular/language-service out of experimental.
我们正在按照我们发布的2.x发布时间表同样的节奏来制定未来6个月的路线图。 您将看到4.0.0的修补程序更新,我们已经开始使用4.1。 我们将继续使Angular越来越小,而且我们将从实验的角度演变@angular/http,@angular/service-worker和@angular/language-service等功能。 You should also stay tuned for updates to our documentation, a stable release of the CLI, and guidance for library authors on packaging.
您还应该继续关注我们的文档的更新,CLI的稳定版本,以及包装上图书馆作者的指导。

【】【】【】【】【】【】【】【】【】【】【】【】【】【】【】【】
【】【】【】【】【】【】【】【】【】【】【】【】【】【】【】【】
angular公开支持的接口:
https://github.com/angular/angular/blob/master/docs/PUBLIC_API.md

Supported Public API Surface of Angular
Angular公开支持的API接口 Our SemVer, timed-release cycle and deprecation policy currently applies to these npm packages:

@angular/core
@angular/common
@angular/platform-browser
@angular/platform-browser-dynamic
@angular/platform-server
@angular/platform-webworker
@angular/platform-webworker-dynamic
@angular/upgrade
@angular/router
@angular/forms
@angular/http

One intentional omission from this list is @angular/compiler, which is currently considered a low level api and is subject to internal changes. These changes will not affect any applications or libraries using the higher-level apis (the command line interface or JIT compilation via @angular/platform-browser-dynamic). Only very specific use-cases require direct access to the compiler API (mostly tooling integration for IDEs, linters, etc). If you are working on this kind of integration, please reach out to us first.
这个列表中的一个有意的遗漏是@angular/compiler,目前被认为是一个低级别的api,并且受到内部的改变。 这些更改不会影响使用更高级别api们(命令行界面或通过@angular/platform-browser-dynamic进行的JIT编译)的任何应用程序或库。 只有非常具体的用例需要直接访问编译器API(主要用于IDE,linters等工具集成)。 如果您正在开展这种整合,请先与我们联系。
Additionally only the command line usage (not direct use of APIs) of @angular/compiler-cli is covered.
另外,仅覆盖了@ angular / compiler-cli的命令行用法。(不直接使用api)
Other projects developed by the Angular team like angular-cli, Angular Material, will be covered by these or similar guarantees in the future as they mature.
angular团队开发的其他项目,如angular-cli,angular-material,将在未来成熟时受到这些或类似的保证。(下面写出了这些保证)
Within the supported packages, we provide guarantees for:
在支持的包中,我们提供保证:
symbols exported via the main entry point (e.g. @angular/core) and testing entry point (e.g. @angular/core/testing). This applies to both runtime/JavaScript values and TypeScript types.
通过主入口点(e.g. @angular/core)和测试入口点(e.g. @angular/core/testing)导出的符号。 这适用于runtime/ JavaScript值和TypeScript类型。
symbols exported via global namespace ng (e.g. ng.core)
通过全局命名空间ng导出的符号(例如ng.core)
bundles located in the bundles/ directory of our npm packages (e.g. @angular/core/bundles/core.umd.js)
捆绑包位于我们的npm软件包的捆绑包/目录中(例如@angular/core/bundles/core.umd.js)

We explicitly don't consider the following to be our public API surface:
我们明确不认为以下是我们的公共API接口:
any file/import paths within our package except for the /, /testing and /bundles/* 我们包中的任何文件/导入路径,除了/,/ testing和/ bundles / *(比如,公开的接口是到@angular/core但是你用了@angular/core/aaa,那么会出问题)
constructors of injectable classes (services and directives) - please use DI to obtain instances of these classes
可注入类的构造函数(服务和指令) - 请使用DI来获取这些类的实例
any class members or symbols marked as private, or prefixed with underscore () and barred latin o (ɵ)
标记为私有的任何类成员或符号,或带下划线(
)和禁止拉丁语(ɵ)
extending any of our classes unless the support for this is specifically documented in the API docs
扩展我们的任何类,除非对API的支持具体记录在API文档中
the contents and API surface of the code generated by Angular's compiler (with one notable exception: the existence and name of NgModuleFactory instances exported from generated code is guaranteed)
由Angular编译器生成的代码的内容和API接口(有一个显着的例外:保证从生成的代码导出的NgModuleFactory实例的存在和名称)

⚠️ **GitHub.com Fallback** ⚠️