Skip to content

Commit

Permalink
docs: replace code line
Browse files Browse the repository at this point in the history
  • Loading branch information
jbogarthyde committed Apr 3, 2018
1 parent 10b7f85 commit e73e1d9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions aio/content/tutorial/toh-pt4.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ in the `HeroesComponent`, in the `AppComponent`, in the `AppModule`. You could h

By default, the Angular CLI command `ng generate service` registers a provider with the _root injector_ for your service. When you provide it at the root level, Angular creates a single, shared instance of HeroService and injects into any class that asks for it. You can modify this and register your service at different levels (HeroesComponent, AppModule) based on your use case.

The `@Injectable()` decorator accepts a metadata object for the service, the same way the `@Component()` decorator did for your component classes. One of the metadata values specifies that this class provides the defined service at one of the available levels. If you look at the `@Injectable()` statement right before the `HeroService` class definition, you can see that the `providedIn` metadata value is "root":
The `@Injectable()` decorator accepts a metadata object for the service, the same way the `@Component()` decorator did for your component classes. One of the metadata values specifies that this class provides the defined service at one of the available levels. If you look at the `@Injectable()` statement right before the `HeroService` class definition, you can see that the `providedIn` metadata value is `root`:

<code-example path="toh-pt4/src/app/hero.service.2.ts" linenums="false" title="src/app/app.service.ts (provide service)" region="provider">
</code-example>
```
@Injectable({providedIn: root})
```

When you provide a service at the root level, Angular creates a single, shared instance of `HeroService` and injects into any class that asks for it.

Expand Down

0 comments on commit e73e1d9

Please sign in to comment.