diff --git a/public/docs/_examples/cb-dependency-injection/e2e-spec.ts b/public/docs/_examples/cb-dependency-injection/e2e-spec.ts
index 2beb08af94..29a8822110 100644
--- a/public/docs/_examples/cb-dependency-injection/e2e-spec.ts
+++ b/public/docs/_examples/cb-dependency-injection/e2e-spec.ts
@@ -35,16 +35,11 @@ describe('Dependency Injection Cookbook', function () {
expect(sortedHero).toBeDefined();
});
- it('should render Hero of the Month when DI deps are defined using provide()', function () {
+ it('should render Hero of the Month', function () {
let heroOfTheMonth = element.all(by.xpath('//h3[text()="Hero of the month"]')).get(0);
expect(heroOfTheMonth).toBeDefined();
});
- it('should render Hero of the Month when DI deps are defined using provide object literal', function () {
- let heroOfTheMonth = element.all(by.xpath('//h3[text()="Hero of the month 2"]')).get(0);
- expect(heroOfTheMonth).toBeDefined();
- });
-
it('should render Hero Bios', function () {
let heroBios = element.all(by.xpath('//h3[text()="Hero Bios"]')).get(0);
expect(heroBios).toBeDefined();
@@ -60,16 +55,11 @@ describe('Dependency Injection Cookbook', function () {
expect(magmaPhone).toBeDefined();
});
- it('should render Hero-of-the-Month runner-ups when DI deps are defined using provide()', function () {
+ it('should render Hero-of-the-Month runner-ups', function () {
let runnersUp = element(by.id('rups1')).getText();
expect(runnersUp).toContain('RubberMan, Mr. Nice');
});
- it('should render Hero-of-the-Month runner-ups when DI deps are defined using provide object literal', function () {
- let runnersUp = element(by.id('rups2')).getText();
- expect(runnersUp).toContain('RubberMan, Mr. Nice');
- });
-
it('should render DateLogger log entry in Hero-of-the-Month', function () {
let logs = element.all(by.id('logs')).get(0).getText();
expect(logs).toContain('INFO: starting up at');
diff --git a/public/docs/_examples/cb-dependency-injection/ts/app/app.component.html b/public/docs/_examples/cb-dependency-injection/ts/app/app.component.html
index 0e1d15932d..a715e484fe 100644
--- a/public/docs/_examples/cb-dependency-injection/ts/app/app.component.html
+++ b/public/docs/_examples/cb-dependency-injection/ts/app/app.component.html
@@ -23,10 +23,6 @@
Logs:
-useClass
'
:marked
@@ -62,10 +59,8 @@ block dart-diff-const-metadata
For that reason, we can't call functions to get values
to use within an annotation.
Instead, we use constant literals or constant constructors.
- For example, a TypeScript program might use the
- function call `provide(Logger, {useClass: BetterLogger})`,
- which is equivalent to the TypeScript code
- `new Provider(Logger, {useClass: BetterLogger})`.
+ For example, a TypeScript program will use the
+ object literal `{ provide: Logger, useClass: BetterLogger }`.
A Dart annotation would instead use the constant value `const Provider(Logger, useClass: BetterLogger)`.
block dart-diff-const-metadata-ctor
diff --git a/public/docs/ts/latest/cookbook/dependency-injection.jade b/public/docs/ts/latest/cookbook/dependency-injection.jade
index 62fbeacf3c..81fdb5c1c2 100644
--- a/public/docs/ts/latest/cookbook/dependency-injection.jade
+++ b/public/docs/ts/latest/cookbook/dependency-injection.jade
@@ -23,13 +23,11 @@ include ../_util-fns
[Inject the component's DOM element](#component-element)
[Define dependencies with providers](#providers)
- * [The *provide* function](#provide)
+ * [The *provide* object literal](#provide)
* [useValue - the *value provider*](#usevalue)
* [useClass - the *class provider*](#useclass)
* [useExisting - the *alias provider*](#useexisting)
- * [useFactory - the *factory provider*](#usefactory)
-
- [Define providers with object literals](#object-literals)
+ * [useFactory - the *factory provider*](#usefactory)
[Provider token alternatives](#tokens)
* [class-interface](#class-interface)
@@ -406,12 +404,9 @@ figure.image-display
.l-main-section
a(id='provide')
:marked
- #### The *provide* function
+ #### The *provide* object literal
- The imported Angular `provide` function creates an instance of
- the Angular [Provider](../api/core/Provider-class.html) class.
-
- The `provide` function takes a *token* and a *definition object*.
+ The `provide` object literal takes a *token* and a *definition object*.
The *token* is usually a class but [it doesn't have to be](#tokens).
The *definition* object has one main property, (e.g. `useValue`) that indicates how the provider
@@ -543,21 +538,6 @@ a(id='usefactory')
Look at the [live example](/resources/live-examples/cb-dependency-injection/ts/plnkr.html)
for the full source code.
-
-.l-main-section
-:marked
- ## Define providers with object literals
-
-:marked
- In the previous section we learned to use the `provide` method to customize how dependencies are created.
-
- Instead of calling the `provide` function, we can configure providers with _object literals_.
- It's a slightly more concise syntax and we don't have to import the `provide` function.
-
- Here's a set of providers that we saw earlier, re-written with object literals.
-
-+makeExample('cb-dependency-injection/ts/app/hero-of-the-month-literals.component.ts','providers-using-object-literals')(format='.')
-
a(id="tokens")
.l-main-section
:marked
@@ -771,7 +751,7 @@ a(id='alex')
Recall that Angular always adds a component instance to its own injector;
that's why we could inject *Alex* into *Carol* [earlier](#known-parent).
- We write an [*alias provider*](#useexisting) — a `provide` function with a `useExisting` definition —
+ We write an [*alias provider*](#useexisting) — a `provide` object literal with a `useExisting` definition —
that creates an *alternative* way to inject the same component instance
and add that provider to the `providers` array of the `@Component` metadata for the `AlexComponent`:
a(id="alex-providers")
diff --git a/public/docs/ts/latest/guide/dependency-injection.jade b/public/docs/ts/latest/guide/dependency-injection.jade
index 5038d1e64b..9e5ccf2f7d 100644
--- a/public/docs/ts/latest/guide/dependency-injection.jade
+++ b/public/docs/ts/latest/guide/dependency-injection.jade
@@ -508,7 +508,7 @@ code-example(format="nocode").
What matters is that the injector has a provider to go to when it needs a `Logger`.
//- Dart limitation: the provide function isn't const so it cannot be used in an annotation.
-- var __andProvideFn = _docsFor == 'dart' ? '' : 'and provide function';
+- var __andProvideFn = _docsFor == 'dart' ? '' : 'and provide object literal';
#provide
:marked
### The *Provider* class !{__andProvideFn}
@@ -519,31 +519,12 @@ code-example(format="nocode").
+makeExample('dependency-injection/ts/app/providers.component.ts','providers-1')
:marked
- This is actually a short-hand expression for a provider registration that creates a new instance of the
- [Provider](../api/core/Provider-class.html) class.
+ This is actually a short-hand expression for a provider registration using the _provider_ object literal.
-+makeExample('dependency-injection/ts/app/providers.component.ts','providers-2')
-
-block provider-function-etc
- :marked
- The [provide](../api/core/provide-function.html) function is the typical way
- to create a `Provider`:
-
- +makeExample('dependency-injection/ts/app/providers.component.ts','providers-3')
-
- :marked
- Or we can declare a provider in an _object literal_ and skip the `provide` function.
-
- +makeExample('dependency-injection/ts/app/providers.component.ts','providers-3a')
-
- :marked
- Pick the syntax that you prefer. They all do the same thing.
++makeExample('dependency-injection/ts/app/providers.component.ts','providers-3a')
block provider-ctor-args
- var _secondParam = 'provider definition object';
- :marked
- In each syntax, we supply two types of values.
-
//- var _secondParam = _docsFor == 'dart' ? 'named parameter, such as useClass
' : 'provider definition object';
:marked
The first is the [token](#token) that serves as the key for both locating a dependency value
diff --git a/public/docs/ts/latest/guide/router-deprecated.jade b/public/docs/ts/latest/guide/router-deprecated.jade
index 464dc57882..4ac9b99780 100644
--- a/public/docs/ts/latest/guide/router-deprecated.jade
+++ b/public/docs/ts/latest/guide/router-deprecated.jade
@@ -351,7 +351,7 @@ figure.image-display
Providing the router providers at the root makes the Component Router available everywhere in our application.
.l-sub-section
:marked
- Learn about providers, the `provide` function, and injected services in the
+ Learn about providers, the `provide` object literal, and injected services in the
[Dependency Injection chapter](dependency-injection.html).
:marked
### The *AppComponent* shell
@@ -1472,8 +1472,7 @@ code-example(format=".", language="bash").
We can go old-school with the `HashLocationStrategy` by
providing it as the router's `LocationStrategy` during application bootstrapping.
- First, import the `provide` symbol for Dependency Injection and the
- `Location` and `HashLocationStrategy` symbols from the router.
+ Import the `LocationStrategy` and `HashLocationStrategy` symbols from `@angular/common`.
Then *override* the default strategy defined in `ROUTE_PROVIDERS` by
providing the `HashLocationStrategy` later in the `bootstrap` providers array argument: