{ "id": "guide/deprecations", "title": "Deprecated APIs and features", "contents": "\n\n\n
\n mode_edit\n
\n\n\n
\n

Deprecated APIs and featureslink

\n

Angular strives to balance innovation and stability.\nSometimes, 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.

\n

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.

\n

This guide contains a summary of all Angular APIs and features that are currently deprecated.

\n
\n

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.

\n

For step-by-step instructions on how to update to the latest Angular release, use the interactive update guide at update.angular.io.

\n
\n

Indexlink

\n

To help you future-proof your apps, the following table lists all deprecated APIs and features, organized by the release in which they are candidates for removal. Each item is linked to the section later in this guide that describes the deprecation reason and replacement options.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AreaAPI or FeatureMay be removed in
@angular/commonReflectiveInjector v11
@angular/commonCurrencyPipe - DEFAULT_CURRENCY_CODE v11
@angular/common/httpXhrFactory v15
@angular/coreDefaultIterableDiffer v11
@angular/coreReflectiveKey v11
@angular/coreRenderComponentType v11
@angular/coreWrappedValue v12
@angular/formsngModel with reactive forms v11
@angular/upgrade@angular/upgrade v11
@angular/upgradegetAngularLib v11
@angular/upgradesetAngularLib v11
template syntax<template> v11
polyfillsreflect-metadata v11
npm package formatesm5 and fesm5 entry-points in @angular/* npm packages v11
@angular/coredefineInjectable v11
@angular/coreentryComponents v11
@angular/coreANALYZE_FOR_ENTRY_COMPONENTS v11
@angular/routerloadChildren string syntax v11
@angular/core/testingTestBed.get v12
@angular/core/testingasync v12
@angular/formsFormBuilder.group legacy options parameter v14
@angular/routerActivatedRoute params and queryParams propertiesunspecified
template syntax/deep/, >>>, and ::ng-deep unspecified
\n

For information about Angular CDK and Angular Material deprecations, see the changelog.

\n

Deprecated APIslink

\n

This section contains a complete list all of the currently-deprecated APIs, with details to help you plan your migration to a replacement.

\n
\n

Tip: In the API reference section of this doc site, deprecated APIs are indicated by strikethrough. You can filter the API list by Status: deprecated.

\n
\n\n

@angular/commonlink

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
APIReplacementDeprecation announcedNotes
CurrencyPipe - DEFAULT_CURRENCY_CODE{provide: DEFAULT_CURRENCY_CODE, useValue: 'USD'}v9From v11 the default code will be extracted from the locale data given by LOCAL_ID, rather than USD.
\n\n

@angular/common/httplink

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
APIReplacementDeprecation announcedNotes
XhrFactoryXhrFactory in @angular/commonv12The XhrFactory has moved from @angular/common/http to @angular/common.
\n\n

@angular/corelink

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
APIReplacementDeprecation announcedNotes
DefaultIterableDiffern/av4Not part of public API.
ReflectiveInjectorInjector.createv5See ReflectiveInjector
ReflectiveKeynonev5none
defineInjectableɵɵdefineInjectablev8Used only in generated code. No source code should depend on this API.
entryComponentsnonev9See entryComponents
ANALYZE_FOR_ENTRY_COMPONENTSnonev9See ANALYZE_FOR_ENTRY_COMPONENTS
WrappedValuenonev10See removing WrappedValue
asyncwaitForAsyncv11The async function from @angular/core/testing has been renamed to waitForAsync in order to avoid confusion with the native JavaScript async syntax. The existing function is deprecated and will be removed in a future version.
[ ViewChildren.emitDistinctChangesOnly / ContentChildren.emitDistinctChangesOnlynone (was part of issue #40091) ]This is a temporary flag introduced as part of bugfix of issue #40091 and will be removed.
\n\n

@angular/core/testinglink

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
APIReplacementDeprecation announcedNotes
TestBed.getTestBed.injectv9Same behavior, but type safe.
asyncwaitForAsyncv10Same behavior, but rename to avoid confusion.
\n\n

@angular/formslink

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
APIReplacementDeprecation announcedNotes
ngModel with reactive formsFormControlDirectivev6none
FormBuilder.group legacy options parameterAbstractControlOptions parameter valuev11none
\n\n

@angular/upgradelink

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
APIReplacementDeprecation announcedNotes
All entry points@angular/upgrade/staticv5See Upgrading from AngularJS.
\n\n

@angular/upgrade/staticlink

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
APIReplacementDeprecation announcedNotes
getAngularLibgetAngularJSGlobalv5See Upgrading from AngularJS.
setAngularLibsetAngularJSGlobalv5See Upgrading from AngularJS.
\n\n

Deprecated featureslink

\n

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 section above. It also includes deprecated API usage scenarios or API combinations, to augment the information above.

\n\n

Bazel builder and schematicslink

\n

Bazel builder and schematics were introduced in Angular Labs to let users try out Bazel without having to manage Bazel version and BUILD files.\nThis feature has been deprecated. For more information, please refer to the migration doc.

\n\n

Web Tracing Framework integrationlink

\n

Angular previously has supported an integration with the Web Tracing Framework (WTF) for performance testing of Angular applications. This integration has not been maintained and defunct. As a result, the integration was deprecated in Angular version 8 and due to no evidence of any existing usage removed in version 9.

\n\n

/deep/, >>> and :ng-deep component style selectorslink

\n

The shadow-dom-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.

\n

For more information, see /deep/, >>>, and ::ng-deep\nin the Component Styles guide.

\n\n

<template> taglink

\n

The <template> tag was deprecated in v4 to avoid colliding with the DOM's element of the same name (such as when using web components). Use <ng-template> instead. For more information, see the Ahead-of-Time Compilation guide.

\n\n

ngModel with reactive formslink

\n

Support for using the ngModel input property and ngModelChange event with reactive\nform directives has been deprecated in Angular v6 and will be removed in a future version\nof Angular.

\n

Now deprecated:

\n\n<input [formControl]=\"control\" [(ngModel)]=\"value\">\n\n\nthis.value = 'some value';\n\n

This has been deprecated for several reasons. First, developers have found this pattern\nconfusing. It seems like the actual ngModel directive is being used, but in fact it's\nan input/output property named ngModel on the reactive form directive that\napproximates some, but not all, of the directive's behavior.\nIt allows getting and setting a value and intercepting value events, but\nsome of ngModel's other features, such as\ndelaying updates withngModelOptions or exporting the directive, don't work.

\n

In addition, this pattern mixes template-driven and reactive forms strategies, which\nprevents taking advantage of the full benefits of either strategy.\nSetting the value in the template violates the template-agnostic\nprinciples behind reactive forms, whereas adding a FormControl/FormGroup layer in\nthe class removes the convenience of defining forms in the template.

\n

To update your code before support is removed, you'll want to decide whether to stick\nwith reactive form directives (and get/set values using reactive forms patterns) or\nswitch over to template-driven directives.

\n

After (choice 1 - use reactive forms):

\n\n<input [formControl]=\"control\">\n\n\nthis.control.setValue('some value');\n\n

After (choice 2 - use template-driven forms):

\n\n<input [(ngModel)]=\"value\">\n\n\nthis.value = 'some value';\n\n

By default, when you use this pattern, you will see a deprecation warning once in dev\nmode. You can choose to silence this warning by providing a config for\nReactiveFormsModule at import time:

\n\nimports: [\n ReactiveFormsModule.withConfig({warnOnNgModelWithFormControl: 'never'});\n]\n\n

Alternatively, you can choose to surface a separate warning for each instance of this\npattern with a config value of \"always\". This may help to track down where in the code\nthe pattern is being used as the code is being updated.

\n\n

ReflectiveInjectorlink

\n

In v5, Angular replaced the ReflectiveInjector with the StaticInjector. The injector no longer requires the Reflect polyfill, reducing application size for most developers.

\n

Before:

\n\nReflectiveInjector.resolveAndCreate(providers);\n\n

After:

\n\nInjector.create({providers});\n\n\n

loadChildren string syntaxlink

\n

When Angular first introduced lazy routes, there wasn't browser support for dynamically loading additional JavaScript. Angular created our own scheme using the syntax loadChildren: './lazy/lazy.module#LazyModule' and built tooling to support it. Now that ECMAScript dynamic import is supported in many browsers, Angular is moving toward this new syntax.

\n

In version 8, the string syntax for the loadChildren route specification was deprecated, in favor of new syntax that uses import() syntax.

\n

Before:

\n\nconst routes: Routes = [{\n path: 'lazy',\n // The following string syntax for loadChildren is deprecated\n loadChildren: './lazy/lazy.module#LazyModule'\n}];\n\n

After:

\n\nconst routes: Routes = [{\n path: 'lazy',\n // The new import() syntax\n loadChildren: () => import('./lazy/lazy.module').then(m => m.LazyModule)\n}];\n\n
\n

Version 8 update: When you update to version 8, the ng update command performs the transformation automatically. Prior to version 7, the import() syntax only works in JIT mode (with view engine).

\n
\n
\n

Declaration syntax: It's important to follow the route declaration syntax loadChildren: () => import('...').then(m => m.ModuleName) to allow ngc to discover the lazy-loaded module and the associated NgModule. You can find the complete list of allowed syntax constructs here. These restrictions will be relaxed with the release of Ivy since it'll no longer use NgFactories.

\n
\n\n

ActivatedRoute params and queryParams propertieslink

\n

ActivatedRoute contains two properties that are less capable than their replacements and may be deprecated in a future Angular version.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
PropertyReplacement
paramsparamMap
queryParamsqueryParamMap
\n

For more information see the Getting route information section of the Router guide.

\n\n

Dependency on a reflect-metadata polyfill in JIT modelink

\n

Angular applications, and specifically applications that relied on the JIT compiler, used to require a polyfill for the reflect-metadata APIs.

\n

The need for this polyfill was removed in Angular version 8.0 (see #14473), rendering the presence of the poylfill in most Angular applications unnecessary. Because the polyfill can be depended on by 3rd-party libraries, instead of removing it from all Angular projects, we are deprecating the requirement for this polyfill as of version 8.0. This should give library authors and application developers sufficient time to evaluate if they need the polyfill, and perform any refactoring necessary to remove the dependency on it.

\n

In a typical Angular project, the polyfill is not used in production builds, so removing it should not impact production applications. The goal behind this removal is overall simplification of the build setup and decrease in the number of external dependencies.

\n\n

@ViewChild() / @ContentChild() static resolution as the defaultlink

\n

See the dedicated migration guide for static queries.

\n\n

@ContentChild() / @Input() used togetherlink

\n

The following pattern is deprecated:

\n\n@Input() @ContentChild(TemplateRef) tpl !: TemplateRef<any>;\n\n

Rather than using this pattern, separate the two decorators into their own\nproperties and add fallback logic as in the following example:

\n\n@Input() tpl !: TemplateRef<any>;\n@ContentChild(TemplateRef) inlineTemplate !: TemplateRef<any>;\n\n\n

Cannot assign to template variableslink

\n

In the following example, the two-way binding means that optionName\nshould be written when the valueChange event fires.

\n\n<option *ngFor=\"let optionName of options\" [(value)]=\"optionName\"></option>\n\n

However, in practice, Angular simply ignores two-way bindings to template variables. Starting in version 8, attempting to write to template variables is deprecated. In a future version, we will throw to indicate that the write is not supported.

\n\n<option *ngFor=\"let optionName of options\" [value]=\"optionName\"></option>\n\n\n

Binding to innerText in platform-serverlink

\n

Domino, which is used in server-side rendering, doesn't support innerText, so in platform-server's \"domino adapter\", there was special code to fall back to textContent if you tried to bind to innerText.

\n

These two properties have subtle differences, so switching to textContent under the hood can be surprising to users. For this reason, we are deprecating this behavior. Going forward, users should explicitly bind to textContent when using Domino.

\n\n

wtfStartTimeRange and all wtf* APIslink

\n

All of the wtf* APIs are deprecated and will be removed in a future version.

\n\n

entryComponents and ANALYZE_FOR_ENTRY_COMPONENTS no longer requiredlink

\n

Previously, the entryComponents array in the NgModule definition was used to tell the compiler which components would be created and inserted dynamically. With Ivy, this isn't a requirement anymore and the entryComponents array can be removed from existing module declarations. The same applies to the ANALYZE_FOR_ENTRY_COMPONENTS injection token.

\n\n

ModuleWithProviders type without a genericlink

\n

Some Angular libraries, such as @angular/router and @ngrx/store, implement APIs that return a type called ModuleWithProviders (typically via a method named forRoot()).\nThis type represents an NgModule along with additional providers.\nAngular version 9 deprecates use of ModuleWithProviders without an explicitly generic type, where the generic type refers to the type of the NgModule.\nIn a future version of Angular, the generic will no longer be optional.

\n

If you're using the CLI, ng update should migrate your code automatically.\nIf you're not using the CLI, you can add any missing generic types to your application manually.\nFor example:

\n

Before

\n\n@NgModule({...})\nexport class MyModule {\n static forRoot(config: SomeConfig): ModuleWithProviders {\n return {\n ngModule: SomeModule,\n providers: [\n {provide: SomeConfig, useValue: config}\n ]\n };\n }\n}\n\n

After

\n\n@NgModule({...})\nexport class MyModule {\n static forRoot(config: SomeConfig): ModuleWithProviders<SomeModule> {\n return {\n ngModule: SomeModule,\n providers: [\n {provide: SomeConfig, useValue: config }\n ]\n };\n }\n}\n\n\n

WrappedValuelink

\n

The purpose of WrappedValue is to allow the same object instance to be treated as different for the purposes of change detection.\nIt is commonly used with the async pipe in the case where the Observable produces the same instance of the value.

\n

Given that this use case is relatively rare and special handling impacts application performance, we have deprecated it in v10.\nNo replacement is planned for this deprecation.

\n

If you rely on the behavior that the same object instance should cause change detection, you have two options:

\n\n

Internet Explorer 11link

\n

Angular support for Microsoft's Internet Explorer 11 (IE11) is deprecated. Maintaining support for IE11 incurs ongoing costs, including increased bundle size, code complexity, and test load. Global usage of IE11 has fallen to a point where these costs no longer warrant the additional maintenance effort. Ending IE11 support additionally allows Angular to take advantage of platform APIs present only in evergreen browsers.

\n

Microsoft announced that its 365 services will no longer support IE11 starting August 17, 2021. Microsoft previously ended support for IE11 in Microsoft Teams on November 30, 2020. For more information, see Microsoft 365 apps say farewell to Internet Explorer 11.

\n\n

Deprecated CLI APIs and Optionslink

\n

This section contains a complete list all of the currently deprecated CLI flags.

\n

@angular-devkit/build-angularlink

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
API/OptionMay be removed inNotes
extractCss v13No longer required to disable CSS extraction during development.
i18nFormat v12Format is now automatically detected.
i18nLocale v12New localization option in version 9 and later.
hmrWarning v13No longer has an effect.
servePathDefaultWarning v13No longer has an effect.
\n

@schematics/angularlink

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
API/OptionMay be removed inNotes
entryComponent v12No longer needed with Ivy.
lintFix v12Deprecated as part of TSLint deprecation.
\n\n

Removed APIslink

\n

The following APIs have been removed starting with version 11.0.0*:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
PackageAPIReplacementNotes
@angular/routerpreserveQueryParamsqueryParamsHandling
\n

*To see APIs removed in version 10, check out this guide on the version 10 docs site.

\n\n

esm5 and fesm5 code formats in @angular/* npm packageslink

\n

As of Angular v8, the CLI primarily consumes the fesm2015 variant of the code distributed via @angular/* npm packages.\nThis renders the esm5 and fesm5 distributions obsolete and unnecessary, adding bloat to the package size and slowing down npm installations.

\n

This removal has no impact on CLI users, unless they modified their build configuration to explicitly consume these code distributions.

\n

Any application still relying on the esm5 and fesm5 as the input to its build system will need to ensure that the build pipeline is capable of accepting JavaScript code conforming to ECMAScript 2015 (ES2015) language specification.

\n

Note that this change doesn't make existing libraries distributed in this format incompatible with the Angular CLI.\nThe CLI will fall back and consume libraries in less desirable formats if others are not available.\nHowever, we do recommend that libraries ship their code in ES2015 format in order to make builds faster and build output smaller.

\n

In practical terms, the package.json of all @angular packages has changed in the following way:

\n

Before:

\n\n{\n \"name\": \"@angular/core\",\n \"version\": \"9.0.0\",\n \"main\": \"./bundles/core.umd.js\",\n \"module\": \"./fesm5/core.js\",\n \"es2015\": \"./fesm2015/core.js\",\n \"esm5\": \"./esm5/core.js\",\n \"esm2015\": \"./esm2015/core.js\",\n \"fesm5\": \"./fesm5/core.js\",\n \"fesm2015\": \"./fesm2015/core.js\",\n ...\n}\n\n

After:

\n\n{\n \"name\": \"@angular/core\",\n \"version\": \"10.0.0\",\n \"main\": \"./bundles/core.umd.js\",\n \"module\": \"./fesm2015/core.js\",\n \"es2015\": \"./fesm2015/core.js\",\n \"esm2015\": \"./esm2015/core.js\",\n \"fesm2015\": \"./fesm2015/core.js\",\n ...\n}\n\n

For more information about the npm package format, see the Angular Package Format spec.

\n\n

Style Sanitization for [style] and [style.prop] bindingslink

\n

Angular used to sanitize [style] and [style.prop] bindings to prevent malicious code from being inserted through javascript: expressions in CSS url() entries. However, most modern browsers no longer support the usage of these expressions, so sanitization was only maintained for the sake of IE 6 and 7. Given that Angular does not support either IE 6 or 7 and sanitization has a performance cost, we will no longer sanitize style bindings as of version 10 of Angular.

\n\n \n
\n\n\n" }