Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(core): deprecate providedIn: NgModule and providedIn: 'any' #47616

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions aio/content/guide/deprecations.md
Expand Up @@ -35,6 +35,7 @@ v11 - v14
v12 - v15
v13 - v16
v14 - v17
v15 - v18
-->

| Area | API or Feature | May be removed in |
Expand All @@ -57,6 +58,7 @@ v14 - v17
| `@angular/core` | [`ComponentFactory`](#core) | <!-- v13 --> v16 |
| `@angular/core` | [`ComponentFactoryResolver`](#core) | <!-- v13 --> v16 |
| `@angular/core` | [`CompilerOptions.useJit and CompilerOptions.missingTranslation config options`](#core) | <!-- v13 --> v16 |
| `@angular/core` | NgModule and `'any'` options for [`providedIn`](#core) | <!-- v15 --> v17 |
| `@angular/platform-browser-dynamic` | [`JitCompilerFactory`](#platform-browser-dynamic) | <!-- v13 --> v16 |
| `@angular/platform-browser-dynamic` | [`RESOURCE_CACHE_PROVIDER`](#platform-browser-dynamic) | <!-- v13 --> v16 |
| `@angular/forms` | [`ngModel` with reactive forms](#ngmodel-reactive) | <!-- v6 --> v11 |
Expand Down Expand Up @@ -141,6 +143,8 @@ In the [API reference section](api) of this site, deprecated APIs are indicated
| [`ComponentFactory`](api/core/ComponentFactory) | Use non-factory based framework APIs. | v13 | Since Ivy, Component factories are not required. Angular provides other APIs where Component classes can be used directly. |
| [`ComponentFactoryResolver`](api/core/ComponentFactoryResolver) | Use non-factory based framework APIs. | v13 | Since Ivy, Component factories are not required, thus there is no need to resolve them. |
| [`CompilerOptions.useJit and CompilerOptions.missingTranslation config options`](api/core/CompilerOptions) | none | v13 | Since Ivy, those config options are unused, passing them has no effect. |
| [`providedIn`](api/core/Injectable#providedIn) with NgModule | Prefer `'root'` providers, or use NgModule `providers` if scoping to an NgModule is necessary | v15 | none |
| [`providedIn: 'any'`](api/core/Injectable#providedIn) | none | v15 | This option has confusing semantics and nearly zero usage. |

<a id="testing"></a>

Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/di/injectable.ts
Expand Up @@ -64,7 +64,8 @@ export interface Injectable {
/**
* Determines which injectors will provide the injectable.
*
* - `Type<any>` - associates the injectable with an `@NgModule` or other `InjectorType`,
* - `Type<any>` - associates the injectable with an `@NgModule` or other `InjectorType`. This
* option is DEPRECATED.
* - 'null' : Equivalent to `undefined`. The injectable is not provided in any scope automatically
* and must be added to a `providers` array of an [@NgModule](api/core/NgModule#providers),
* [@Component](api/core/Directive#providers) or [@Directive](api/core/Directive#providers).
Expand All @@ -75,7 +76,7 @@ export interface Injectable {
* - 'platform' : A special singleton platform injector shared by all
* applications on the page.
* - 'any' : Provides a unique instance in each lazy loaded module while all eagerly loaded
* modules share one instance.
* modules share one instance. This option is DEPRECATED.
*
*/
providedIn?: Type<any>|'root'|'platform'|'any'|null;
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/di/injection_token.ts
Expand Up @@ -35,8 +35,11 @@ import {ɵɵdefineInjectable} from './interface/defs';
* As you can see in the Tree-shakable InjectionToken example below.
*
* Additionally, if a `factory` is specified you can also specify the `providedIn` option, which
* overrides the above behavior and marks the token as belonging to a particular `@NgModule`. As
* mentioned above, `'root'` is the default value for `providedIn`.
* overrides the above behavior and marks the token as belonging to a particular `@NgModule` (note:
* this option is now deprecated). As mentioned above, `'root'` is the default value for
* `providedIn`.
*
* The `providedIn: NgModule` and `providedIn: 'any'` options are deprecated.
*
* @usageNotes
* ### Basic Examples
Expand Down