+
-This is a typical "*service-in-service*" scenario:
-you inject the `MessageService` into the `HeroService` which is injected into the `HeroesComponent`.
+Este es un escenario típico de "*servicio en servicio*":
+inyecta el `MessageService` en el `HeroService` que se inyecta en el `HeroesComponent`.
-### Send a message from `HeroService`
+### Enviar un mensaje desde `HeroService`
-Modify the `getHeroes()` method to send a message when the heroes are fetched.
+Modifique el método `getHeroes()` para enviar un mensaje cuando se busquen los héroes.
-### Display the message from `HeroService`
+### Mostrar el mensaje de `HeroService`
-The `MessagesComponent` should display all messages,
-including the message sent by the `HeroService` when it fetches heroes.
+El `MessagesComponent` debería mostrar todos los mensajes,
+incluido el mensaje enviado por el `HeroService` cuando busca héroes.
-Open `MessagesComponent` and import the `MessageService`.
+Abra `MessagesComponent` e importe el `MessageService`
-Modify the constructor with a parameter that declares a **public** `messageService` property.
-Angular will inject the singleton `MessageService` into that property
-when it creates the `MessagesComponent`.
+Modifique el constructor con un parámetro que declare una propiedad `messageService` **publica**.
+Angular inyectará el único `MessageService` en esa propiedad
+cuando crea el `MessagesComponent`.
-The `messageService` property **must be public** because you're going to bind to it in the template.
+La propiedad `messageService` **debe ser pública** porque la vinculará en la plantilla.
-Angular only binds to _public_ component properties.
+Angular solo se une a las propiedades _publicas_ del componente .
-### Bind to the `MessageService`
-
-Replace the CLI-generated `MessagesComponent` template with the following.
+### Enlazar al `MessageService`
+Reemplace la plantilla `MessagesComponent` generada por CLI con lo siguiente.
+
-This template binds directly to the component's `messageService`.
+Esta plantilla se une directamente al componente `messageService` del componente.
-* The `*ngIf` only displays the messages area if there are messages to show.
+* `*NgIf` solo muestra el área de mensajes si hay mensajes para mostrar.
-* An `*ngFor` presents the list of messages in repeated `
` elements.
+* Un `*ngFor` presenta la lista de mensajes en elementos repetidos`
`.
-* An Angular [event binding](guide/event-binding) binds the button's click event
-to `MessageService.clear()`.
+* Un [enlace de evento](guide/template-syntax) en angular une el evento de clic del botón
+a `MessageService.clear ()`.
-The messages will look better when you add the private CSS styles to `messages.component.css`
-as listed in one of the ["final code review"](#final-code-review) tabs below.
+Los mensajes se verán mejor cuando agregue los estilos CSS privados a `messages.component.css`
+como se indica en una de las pestañas ["revisión de código final"](#final-code-review) a continuación.
-## Add additional messages to hero service
+## Agregar mensajes adicionales al servicio de héroe
-The following example shows how to send and display a message each time the user clicks on
-a hero, showing a history of the user's selections. This will be helpful when you get to the
-next section on [Routing](tutorial/toh-pt5).
+El siguiente ejemplo muestra cómo enviar y mostrar un mensaje cada vez que el usuario hace clic en
+un héroe, que muestra un historial de las selecciones del usuario. Esto será útil cuando llegues a
+siguiente sección sobre [Enrutamiento](tutorial/toh-pt5).
-The browser refreshes and the page displays the list of heroes.
-Refresh the browser to see the list of heroes, and scroll to the bottom to see the
-messages from the HeroService. Each time you click a hero, a new message appears to record
-the selection. Use the "clear" button to clear the message history.
+El navegador se actualizará y la página mostrará la lista de héroes.
+Actualiza el navegador para ver la lista de héroes y desplázate hacia abajo para ver
+mensajes del HeroService. Cada vez que haces clic en un héroe, aparece un nuevo mensaje para grabar
+la selección. Use el botón "borrar" para borrar el historial de mensajes.
{@a final-code-review}
-## Final code review
+## Revisión final del código
-Here are the code files discussed on this page.
+Aquí están los archivos de código discutidos en esta página.
-
-
@@ -432,15 +436,16 @@ Here are the code files discussed on this page.
-## Summary
+## Resumen
-* You refactored data access to the `HeroService` class.
-* You registered the `HeroService` as the _provider_ of its service at the root level so that it can be injected anywhere in the app.
-* You used [Angular Dependency Injection](guide/dependency-injection) to inject it into a component.
-* You gave the `HeroService` _get data_ method an asynchronous signature.
-* You discovered `Observable` and the RxJS _Observable_ library.
-* You used RxJS `of()` to return an observable of mock heroes (`Observable`).
-* The component's `ngOnInit` lifecycle hook calls the `HeroService` method, not the constructor.
-* You created a `MessageService` for loosely-coupled communication between classes.
-* The `HeroService` injected into a component is created with another injected service,
- `MessageService`.
+* Refactorizó el acceso a datos a la clase `HeroService`.
+* Registro el `HeroService` como el _proveedor_ de su servicio en el nivel raíz para que pueda inyectarse en cualquier lugar de la aplicación.
+* Usó la [Inyección de dependencia angular](guide/dependency-injection) para inyectarlo en un componente.
+* Le dio al `HeroService` el método _get data_ una firma asincrónica.
+* Descubrio `Observable` y la biblioteca RxJS _Observable_.
+* Usó RxJS `of ()` para devolver un observable de héroes simulados (`Observable `).
+* El lifecycle hook (gancho del ciclo de vida) `ngOnInit` del componente llama al método `HeroService`, no al constructor.
+* Creó un `MessageService` para una comunicación débilmente acoplada entre clases.
+* El `HeroService` inyectado en un componente se crea con otro servicio inyectado,
+ `MessageService`.
+
\ No newline at end of file