docs: fix the sequence of creating class in HTTP tutorial (#30566)
For more accurate procedure of creating a class in the "Tour of Heroes" app, updated the sequence of creating one class. PR Close #30566
This commit is contained in:
parent
af4925f374
commit
24ca8ba7ce
@ -56,8 +56,24 @@ Install the *In-memory Web API* package from _npm_
|
|||||||
npm install angular-in-memory-web-api --save
|
npm install angular-in-memory-web-api --save
|
||||||
</code-example>
|
</code-example>
|
||||||
|
|
||||||
Import the `HttpClientInMemoryWebApiModule` and the `InMemoryDataService` class,
|
|
||||||
which you will create in a moment.
|
The class `src/app/in-memory-data.service.ts` is generated by the following command:
|
||||||
|
|
||||||
|
<code-example language="sh" class="code-shell">
|
||||||
|
ng generate service InMemoryData
|
||||||
|
</code-example>
|
||||||
|
|
||||||
|
This class has the following content:
|
||||||
|
|
||||||
|
<code-example path="toh-pt6/src/app/in-memory-data.service.ts" region="init" header="src/app/in-memory-data.service.ts" linenums="false"></code-example>
|
||||||
|
|
||||||
|
This file replaces `mock-heroes.ts`, which is now safe to delete.
|
||||||
|
|
||||||
|
When your server is ready, detach the *In-memory Web API*, and the app's requests will go through to the server.
|
||||||
|
|
||||||
|
Now back to the `HttpClient` story.
|
||||||
|
|
||||||
|
Import the `HttpClientInMemoryWebApiModule` and the `InMemoryDataService` class.
|
||||||
|
|
||||||
<code-example
|
<code-example
|
||||||
path="toh-pt6/src/app/app.module.ts"
|
path="toh-pt6/src/app/app.module.ts"
|
||||||
@ -77,22 +93,6 @@ _after importing the `HttpClientModule`_,
|
|||||||
The `forRoot()` configuration method takes an `InMemoryDataService` class
|
The `forRoot()` configuration method takes an `InMemoryDataService` class
|
||||||
that primes the in-memory database.
|
that primes the in-memory database.
|
||||||
|
|
||||||
The class `src/app/in-memory-data.service.ts` is generated by the following command:
|
|
||||||
|
|
||||||
<code-example language="sh" class="code-shell">
|
|
||||||
ng generate service InMemoryData
|
|
||||||
</code-example>
|
|
||||||
|
|
||||||
This class has the following content:
|
|
||||||
|
|
||||||
<code-example path="toh-pt6/src/app/in-memory-data.service.ts" region="init" header="src/app/in-memory-data.service.ts" linenums="false"></code-example>
|
|
||||||
|
|
||||||
This file replaces `mock-heroes.ts`, which is now safe to delete.
|
|
||||||
|
|
||||||
When your server is ready, detach the *In-memory Web API*, and the app's requests will go through to the server.
|
|
||||||
|
|
||||||
Now back to the `HttpClient` story.
|
|
||||||
|
|
||||||
{@a import-heroes}
|
{@a import-heroes}
|
||||||
## Heroes and HTTP
|
## Heroes and HTTP
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user