diff --git a/aio/content/guide/deprecations.md b/aio/content/guide/deprecations.md index 7903bc9947..edf25915e4 100644 --- a/aio/content/guide/deprecations.md +++ b/aio/content/guide/deprecations.md @@ -1,263 +1,405 @@ # Deprecated APIs and Features +# 弃用的 API 和特性 + + Angular strives to balance innovation and stability. Sometimes, APIs and features become obsolete and need to be removed or replaced so that Angular can stay current with new best practices, changing dependencies, or changes in the (web) platform itself. +Angular 力图兼顾创新与稳定。但有时,API 和特性已经过时,需要进行删除或替换,以便 Angular 可以及时跟上新的最佳实践、依赖项变更或者 Web 平台自身的变化。 + + To make these transitions as easy as possible, we deprecate APIs and features for a period of time before removing them. This gives you time to update your apps to the latest APIs and best practices. +为了让这些转换变得尽可能简单,我们会在删除 API 和特性之前先弃用它们一段时间。让你有时间把应用更新到最新的 API 和最佳实践。 + + This guide contains a summary of all Angular APIs and features that are currently deprecated. +本指南包含了当前不推荐使用的所有 Angular API 和特性的汇总表。 +
- Features and APIs that were deprecated in v6 or earlier are candidates for removal in version 9 or any later major version. For information about Angular's deprecation and removal practices, see [Angular Release Practices](guide/releases#deprecation-practices "Angular Release Practices: Deprecation practices"). +v6 或更早版本中已弃用的特性和 API 将会在版本 9 或更高级版本中删除。要了解 Angular 中关于弃用和删除的实践,参见[Angular 发布实践](guide/releases#deprecation-practices "Angular 发布实践:弃用实践") 。 + + For step-by-step instructions on how to update to the latest Angular release, use the interactive update guide at [update.angular.io](https://update.angular.io). +有关如何更新到最新 Angular 版本的分步说明,请参阅 [update.angular.io](https://update.angular.io) 上的交互式更新指南。 + +
- - ## Deprecated APIs +## 已弃用的 API + + This section contains a complete list all of the currently-deprecated APIs, with details to help you plan your migration to a replacement. +本节包含所有当前已弃用的 API 的完整列表,其中包含一些可帮助你规划如何迁移到其替代品的详细信息。 +
Tip: In the [API reference section](api) of this doc site, deprecated APIs are indicated by ~~strikethrough.~~ You can filter the API list by [**Status: deprecated**](api?status=deprecated). +提示:在本文档站的 [API参考手册部分](api),不推荐使用的 API 会用~~删除线~~标记出来。你可以按[**状态**: 已弃用](api?status=deprecated)来过滤 API 列表。 + +
- - - #### @angular/common -| API | Replacement | Deprecation announced | Notes | -| --- | ----------- | --------------------- | ----- | -| [`DeprecatedI18NPipesModule`](api/common/DeprecatedI18NPipesModule) | [`CommonModule`](api/common/CommonModule#pipes) | v5 | See [Pipes](#i18n-pipes) | - | [`DeprecatedCurrencyPipe`](api/common/DeprecatedCurrencyPipe) | [`CurrencyPipe`](api/common/CurrencyPipe) | v5 | See [Pipes](#i18n-pipes) | - | [`DeprecatedDatePipe`](api/common/DeprecatedDatePipe) | [`DatePipe`](api/common/DatePipe) | v5 | See [Pipes](#i18n-pipes) | - | [`DeprecatedDecimalPipe`](api/common/DeprecatedDecimalPipe) | [`DecimalPipe`](api/common/DecimalPipe) | v5 | See [Pipes](#i18n-pipes) | - | [`DeprecatedPercentPipe`](api/common/DeprecatedPercentPipe) | [`PercentPipe`](api/common/PercentPipe) | v5 | See [Pipes](#i18n-pipes) | - +| API | Replacement | Deprecation announced | Notes | +| ------------------------------------------------------------------- | ----------------------------------------------- | --------------------- | ------------------------ | +| API | 替代品 | 已宣布弃用 | 备注 | +| [`DeprecatedI18NPipesModule`](api/common/DeprecatedI18NPipesModule) | [`CommonModule`](api/common/CommonModule#pipes) | v5 | See [Pipes](#i18n-pipes) | +| [`DeprecatedI18NPipesModule`](api/common/DeprecatedI18NPipesModule) | [`CommonModule`](api/common/CommonModule#pipes) | v5 | 参见[管道](#i18n-pipes) | +| [`DeprecatedCurrencyPipe`](api/common/DeprecatedCurrencyPipe) | [`CurrencyPipe`](api/common/CurrencyPipe) | v5 | See [Pipes](#i18n-pipes) | +| [`DeprecatedCurrencyPipe`](api/common/DeprecatedCurrencyPipe) | [`CurrencyPipe`](api/common/CurrencyPipe) | v5 | 参见[管道](#i18n-pipes) | +| [`DeprecatedDatePipe`](api/common/DeprecatedDatePipe) | [`DatePipe`](api/common/DatePipe) | v5 | See [Pipes](#i18n-pipes) | +| [`DeprecatedDatePipe`](api/common/DeprecatedDatePipe) | [`DatePipe`](api/common/DatePipe) | v5 | 参见[管道](#i18n-pipes) | +| [`DeprecatedDecimalPipe`](api/common/DeprecatedDecimalPipe) | [`DecimalPipe`](api/common/DecimalPipe) | v5 | See [Pipes](#i18n-pipes) | +| [`DeprecatedDecimalPipe`](api/common/DeprecatedDecimalPipe) | [`DecimalPipe`](api/common/DecimalPipe) | v5 | 参见[管道](#i18n-pipes) | +| [`DeprecatedPercentPipe`](api/common/DeprecatedPercentPipe) | [`PercentPipe`](api/common/PercentPipe) | v5 | See [Pipes](#i18n-pipes) | +| [`DeprecatedPercentPipe`](api/common/DeprecatedPercentPipe) | [`PercentPipe`](api/common/PercentPipe) | v5 | 参见[管道](#i18n-pipes) | #### @angular/core -| API | Replacement | Deprecation announced | Notes | -| --- | ----------- | --------------------- | ----- | -| [`CollectionChangeRecord`](api/core/CollectionChangeRecord) | [`IterableChangeRecord`](api/core/IterableChangeRecord) | v4 | none | -| [`DefaultIterableDiffer`](api/core/DefaultIterableDiffer) | n/a | v4 | Not part of public API. | -| [`defineInjectable`](api/core/defineInjectable) | `ɵɵdefineInjectable` | v8 | Used only in generated code. No source code should depend on this API. | -| [`inject`](api/core/inject) | `ɵɵinject` | v8 | Used only in generated code. No source code should depend on this API. | -| [`ReflectiveInjector`](api/core/ReflectiveInjector) | [`Injector.create`](api/core/Injector#create) | v5 | See [`ReflectiveInjector`](#reflectiveinjector) | -| [`ReflectiveKey`](api/core/ReflectiveKey) | none | v5 | none | -| [`RenderComponentType`](api/core/RenderComponentType) | [`RendererType2`](api/core/RendererType2) and [`Renderer2`](api/core/Renderer2) | v4 | none | -| [`Renderer`](api/core/Renderer) | [`Renderer2`](api/core/Renderer2) | v4 | none | -| [`RootRenderer`](api/core/RootRenderer) | [`RendererFactory2`](api/core/RendererFactory2) | v4 | none | -| [`ViewEncapsulation.Native`](api/core/ViewEncapsulation#Native) | [`ViewEncapsulation.ShadowDom`](api/core/ViewEncapsulation#ShadowDom) | v6 | Use the native encapsulation mechanism of the renderer. See [view.ts](https://github.com/angular/angular/blob/3e992e18ebf51d6036818f26c3d77b52d3ec48eb/packages/core/src/metadata/view.ts#L32). +| API | Replacement | Deprecation announced | Notes | +| --------------------------------------------------------------- | -------------------------------------------------------------------------------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| API | 替代品 | 已宣布弃用 | 备注 | +| [`CollectionChangeRecord`](api/core/CollectionChangeRecord) | [`IterableChangeRecord`](api/core/IterableChangeRecord) | v4 | none | +| [`CollectionChangeRecord`](api/core/CollectionChangeRecord) | [`IterableChangeRecord`](api/core/IterableChangeRecord) | v4 | 无 | +| [`DefaultIterableDiffer`](api/core/DefaultIterableDiffer) | n/a | v4 | Not part of public API. | +| [`DefaultIterableDiffer`](api/core/DefaultIterableDiffer) | 不适用 | v4 | 不属于公共 API。 | +| [`defineInjectable`](api/core/defineInjectable) | `ɵɵdefineInjectable` | v8 | Used only in generated code. No source code should depend on this API. | +| [`defineInjectable`](api/core/defineInjectable) | `ɵɵdefineInjectable` | v8 | 仅在生成的代码中使用。没有源码会依赖这个 API。 | +| [`inject`](api/core/inject) | `ɵɵinject` | v8 | Used only in generated code. No source code should depend on this API. | +| [`inject`](api/core/inject) | `ɵɵinject` | v8 | 仅在生成的代码中使用。没有源码会依赖这个 API。 | +| [`ReflectiveInjector`](api/core/ReflectiveInjector) | [`Injector.create`](api/core/Injector#create) | v5 | See [`ReflectiveInjector`](#reflectiveinjector) | +| [`ReflectiveInjector`](api/core/ReflectiveInjector) | [`Injector.create`](api/core/Injector#create) | v5 | 参见 [`ReflectiveInjector`](#reflectiveinjector) | +| [`ReflectiveKey`](api/core/ReflectiveKey) | none | v5 | none | +| [`ReflectiveKey`](api/core/ReflectiveKey) | 无 | v5 | 无 | +| [`RenderComponentType`](api/core/RenderComponentType) | [`RendererType2`](api/core/RendererType2) and [`Renderer2`](api/core/Renderer2) | v4 | none | +| [`RenderComponentType`](api/core/RenderComponentType) | [`RendererType2`](api/core/RendererType2)和[`Renderer2`](api/core/Renderer2) | v4 | 无 | +| [`Renderer`](api/core/Renderer) | [`Renderer2`](api/core/Renderer2) | v4 | none | +| [`Renderer`](api/core/Renderer) | [`Renderer2`](api/core/Renderer2) | v4 | 无 | +| [`RootRenderer`](api/core/RootRenderer) | [`RendererFactory2`](api/core/RendererFactory2) | v4 | none | +| [`RootRenderer`](api/core/RootRenderer) | [`RendererFactory2`](api/core/RendererFactory2) | v4 | 无 | +| [`ViewEncapsulation.Native`](api/core/ViewEncapsulation#Native) | [`ViewEncapsulation.ShadowDom`](api/core/ViewEncapsulation#ShadowDom) | v6 | Use the native encapsulation mechanism of the renderer. See [view.ts](https://github.com/angular/angular/blob/3e992e18ebf51d6036818f26c3d77b52d3ec48eb/packages/core/src/metadata/view.ts#L32). | +| [`ViewEncapsulation.Native`](api/core/ViewEncapsulation#Native) | [`ViewEncapsulation.ShadowDom`](api/core/ViewEncapsulation#ShadowDom) | v6 | 使用渲染器的原生封装方式(Native)。参见 [view.ts](https://github.com/angular/angular/blob/3e992e18ebf51d6036818f26c3d77b52d3ec48eb/packages/core/src/metadata/view.ts#L32) | #### @angular/core/testing -| API | Replacement | Deprecation announced | Notes | -| --- | ----------- | --------------------- | ----- | -| [`TestBed.deprecatedOverrideProvider()`](api/core/testing/TestBed#deprecatedoverrideprovider) | [`TestBed.overrideProvider()`] (api/core/testing/TestBed#overrideprovider) | v7 | none | -| [`TestBedStatic.deprecatedOverrideProvider()`](api/core/testing/TestBedStatic#deprecatedoverrideprovider) | [`TestBedStatic.overrideProvider()`](api/core/testing/TestBedStatic#overrideprovider) | v5 | none | - +| API | Replacement | Deprecation announced | Notes | +| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | --------------------- | ----- | +| API | 替代品 | 已宣布弃用 | 备注 | +| [`TestBed.deprecatedOverrideProvider()`](api/core/testing/TestBed#deprecatedoverrideprovider) | [`TestBed.overrideProvider()`](api/core/testing/TestBed#overrideprovider) | v7 | none | +| [`TestBed.deprecatedOverrideProvider()`](api/core/testing/TestBed#deprecatedoverrideprovider) | [`TestBed.overrideProvider()`](api/core/testing/TestBed#overrideprovider) | v7 | 无 | +| [`TestBedStatic.deprecatedOverrideProvider()`](api/core/testing/TestBedStatic#deprecatedoverrideprovider) | [`TestBedStatic.overrideProvider()`](api/core/testing/TestBedStatic#overrideprovider) | v5 | none | +| [`TestBedStatic.deprecatedOverrideProvider()`](api/core/testing/TestBedStatic#deprecatedoverrideprovider) | [`TestBedStatic.overrideProvider()`](api/core/testing/TestBedStatic#overrideprovider) | v5 | 无 | #### @angular/forms -| API | Replacement | Deprecation announced | Notes | -| --- | ----------- | --------------------- | ----- | -| [`NgFormSelectorWarning`](api/forms/NgFormSelectorWarning) | n/a | v6 | See [ngForm](#ngform). | - +| API | Replacement | Deprecation announced | Notes | +| ---------------------------------------------------------- | ----------- | --------------------- | ------------------------ | +| API | 替代品 | 已宣布弃用 | 备注 | +| [`NgFormSelectorWarning`](api/forms/NgFormSelectorWarning) | n/a | v6 | See [ngForm](#ngform). | +| [`NgFormSelectorWarning`](api/forms/NgFormSelectorWarning) | 不适用 | v6 | 参见 [ngForm](#ngform) 。 | #### @angular/router -| API | Replacement | Deprecation announced | Notes | -| --- | ----------- | --------------------- | ----- | -| [`preserveQueryParams`](api/router/NavigationExtras#preserveQueryParams) | [`queryParamsHandling`](api/router/NavigationExtras#queryParamsHandling) | v4 | none | - +| API | Replacement | Deprecation announced | Notes | +| ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | --------------------- | ----- | +| API | 替代品 | 已宣布弃用 | 备注 | +| [`preserveQueryParams`](api/router/NavigationExtras#preserveQueryParams) | [`queryParamsHandling`](api/router/NavigationExtras#queryParamsHandling) | v4 | none | +| [`preserveQueryParams`](api/router/NavigationExtras#preserveQueryParams) | [`queryParamsHandling`](api/router/NavigationExtras#queryParamsHandling) | v4 | 无 | #### @angular/upgrade -| API | Replacement | Deprecation announced | Notes | -| --- | ----------- | --------------------- | ----- | -| [All entry points](api/upgrade) | [`@angular/upgrade/static`](api/upgrade/static) | v5 | See [Upgrading from AngularJS](guide/upgrade). | - +| API | Replacement | Deprecation announced | Notes | +| ------------------------------- | ----------------------------------------------- | --------------------- | ---------------------------------------------- | +| API | 替代品 | 已宣布弃用 | 备注 | +| [All entry points](api/upgrade) | [`@angular/upgrade/static`](api/upgrade/static) | v5 | See [Upgrading from AngularJS](guide/upgrade). | +| [所有入口点](api/upgrade) | [`@angular/upgrade/static`](api/upgrade/static) | v5 | 参见[从 AngularJS 升级](guide/upgrade) 。 | #### @angular/upgrade/static -| API | Replacement | Deprecation announced | Notes | -| --- | ----------- | --------------------- | ----- | -| [`getAngularLib`](api/upgrade/static/getAngularLib) | [`getAngularJSGlobal`](api/upgrade/static/getAngularJSGlobal) | v5 | See [Upgrading from AngularJS](guide/upgrade). | -[`setAngularLib`](api/upgrade/static/setAngularLib) | [`setAngularJSGlobal`](api/upgrade/static/setAngularJSGlobal) | v5 | See [Upgrading from AngularJS](guide/upgrade). | - - +| API | Replacement | Deprecation announced | Notes | +| --------------------------------------------------- | ------------------------------------------------------------- | --------------------- | ---------------------------------------------- | +| API | 替代品 | 已宣布弃用 | 备注 | +| [`getAngularLib`](api/upgrade/static/getAngularLib) | [`getAngularJSGlobal`](api/upgrade/static/getAngularJSGlobal) | v5 | See [Upgrading from AngularJS](guide/upgrade). | +| [`getAngularLib`](api/upgrade/static/getAngularLib) | [`getAngularJSGlobal`](api/upgrade/static/getAngularJSGlobal) | v5 | 参见[从 AngularJS 升级](guide/upgrade) 。 | +| [`setAngularLib`](api/upgrade/static/setAngularLib) | [`setAngularJSGlobal`](api/upgrade/static/setAngularJSGlobal) | v5 | See [Upgrading from AngularJS](guide/upgrade). | +| [`setAngularLib`](api/upgrade/static/setAngularLib) | [`setAngularJSGlobal`](api/upgrade/static/setAngularJSGlobal) | v5 | 参见[从 AngularJS 升级](guide/upgrade) 。 | {@a deprecated-features} + + ## Deprecated features +## 已弃用的特性 + + This section lists all of the currently-deprecated features, which includes template syntax, configuration options, and any other deprecations not listed in the [Deprecated APIs](#deprecated-apis) section above. It also includes deprecated API usage scenarios or API combinations, to augment the information above. +本节列出了所有当前已弃用的特性,包括模板语法、配置选项,以及前面[已弃用的 API ](#deprecated-apis)部分未列出的其它弃用。它还包括已弃用的 API 用例或 API 组合,以增强上述信息。 {@a component-styles} ### Component styles +### 组件样式 + + The shadow-piercing descendant combinator is deprecated and support is being removed from major browsers and tools. As such, in v4 we deprecated support in Angular for all 3 of `/deep/`, `>>>` and `::ng-deep`. Until removal, `::ng-deep` is preferred for broader compatibility with the tools. +刺穿 Shadow DOM 的 CSS 组合符已经弃用,并且主要的浏览器和工具都已删除它。因此,在 v4 中,Angular 也弃用了对 `/deep/`,`>>>` 和 `::ng-deep` 的支持。在彻底删除它之前,我们首选`::ng-deep` ,以便和各种工具实现更广泛的兼容。 + + For more information, see [/deep/, >>>, and ::ng-deep](guide/component-styles#deprecated-deep--and-ng-deep "Component Styles guide, Deprecated deep and ngdeep") in the Component Styles guide. +欲知详情,参阅“组件样式”一章中的 [/deep/,>>> 和 :: ng-deep](guide/component-styles#deprecated-deep--and-ng-deep "“组件样式”指南,代号为deep和ngdeep")。 + {@a template-tag} -### <template> tag + +### <template> tag + +### <template> 标签 + The `