@@ -87,36 +87,30 @@ include::{common-includes}/gitclone.adoc[]
8787Before you begin the implementation, start the provided REST service so that
8888the artist JSON is available to you.
8989
90- To start the REST service, navigate to the `start` directory and run the Maven
91- `install` and `liberty:start-server` goals:
92-
93- [role='command']
94- ----
95- mvn install liberty:start-server
96- ----
97-
98- After you start the server, you can find your artist JSON at the
99- http://localhost:9080/artists[http://localhost:9080/artists^] URL.
90+ Navigate to the `start` directory to begin.
10091
101- You can rebuild the front end at any time. To do so, run Maven with the
102- `generate-resources` goal:
92+ First, you need to build the front end by running the Maven `generate-resources` goal:
10393[role='command']
10494----
10595mvn generate-resources
10696----
10797
98+ Note that you can rebuild the front end at any time with the Maven `generate-resources` goal.
10899Any local changes to your TypeScript and HTML are picked up when you build the
109- front end. After you start the Open Liberty server, you don't need to restart it.
100+ front end.
110101
102+ [role='command']
103+ include::{common-includes}/devmode-start.adoc[]
104+
105+ You can find your artist JSON at the
106+ http://localhost:9080/artists[http://localhost:9080/artists^] URL.
111107
112108// =================================================================================================
113109// Guide
114110// =================================================================================================
115111
116112== Importing the HTTP client
117113
118- Navigate to the `start` directory to begin.
119-
120114Your application needs a way to communicate with RESTful web services to retrieve their
121115resources. In this case, the provided Angular application needs to communicate with the
122116artists service to retrieve the artists JSON. While there are various ways to perform
@@ -158,19 +152,19 @@ data from the REST API. The component file contains two classes: the service, wh
158152handles data access, and the component itself, which handles the presentation of the
159153data. The provided Angular application already contains a component.
160154
161- app.component.ts
162- [source, javascript, linenums, role="code_column"]
163- ----
164- include::finish/src/main/frontend/src/app/app.component.ts[]
165- ----
166-
167155=== Defining a service to fetch data
168156
169157Services are classes in Angular that are designed to share their functionality across
170158entire applications. A good service performs only one function, and it performs this
171159function well. In this case, the `ArtistsService` class requests artists data from the
172160REST service.
173161
162+ app.component.ts
163+ [source, javascript, linenums, role="code_column hide_tags=providersProperty,importOnInitAndAngularCorePackage"]
164+ ----
165+ include::finish/src/main/frontend/src/app/app.component.ts[]
166+ ----
167+
174168[role="code_command hotspot", subs="quotes"]
175169----
176170#Update the `app.component.ts` file.#
@@ -227,13 +221,19 @@ Components are made up of a TypeScript class annotated with the
227221Update the [hotspot=appComponentClass]`AppComponent` class to use the artists service
228222to fetch the artists data and save it so the component can display it.
229223
224+ app.component.ts
225+ [source, javascript, linenums, role="code_column"]
226+ ----
227+ include::finish/src/main/frontend/src/app/app.component.ts[]
228+ ----
229+
230230[role="code_command hotspot", subs="quotes"]
231231----
232232#Update the `app.component.ts` file.#
233233`src/main/frontend/src/app/app.component.ts`
234234----
235235[role="edit_command_text"]
236- Replace the entire [hotspot=appComponentClass]`AppComponent` class with the
236+ Replace the entire [hotspot=appComponentClass]`AppComponent` class along with the
237237[hotspot=atComponent]`@Component` annotation. Add
238238[hotspot=importOnInitAndAngularCorePackage]`OnInit` to the list of imported classes at
239239the top.
@@ -285,9 +285,9 @@ app.component.html
285285include::finish/src/main/frontend/src/app/app.component.html[]
286286----
287287
288- The template contains a [hotspot=artistsDiv]`div` element that is enumerated using the
288+ The template contains a [hotspot=artistsDiv]`div` element that is enumerated by using the
289289`*ngFor` directive. The `artist` variable is bound to the `artists` member of the
290- component. The div element itself and all elements contained within it are repeated for
290+ component. The [hotspot=artistsDiv]` div` element itself and all elements contained within it are repeated for
291291each artist, and the [hotspot=artistNameAndAlbumsLengthPlaceholders]`{{ artist.name }}`
292292and [hotspot=artistNameAndAlbumsLengthPlaceholders]`{{ artist.albums.length }}`
293293placeholders are populated with the information from each artist. The same strategy is
@@ -313,6 +313,11 @@ bar wrote 1 albums:
313313dj wrote 0 albums:
314314----
315315
316+ If you use the `curl` command to access the web application root URL,
317+ you see only the application root page in HTML. The Angular framework
318+ uses JavaScript to render the HTML to display the application data.
319+ A web browser runs JavaScript, and the `curl` command doesn't.
320+
316321
317322== Testing the Angular client
318323
@@ -329,12 +334,9 @@ following command:
329334mvn generate-resources
330335```
331336
332- When you are done checking the application root, stop the Open Liberty server by
333- running the following command:
334- [role='command']
335- ```
336- mvn liberty:stop-server
337- ```
337+ When you are done checking the application root, exit development mode by
338+ pressing `CTRL+C` in the shell session where you ran the server,
339+ or by typing `q` and then pressing the `enter/return` key.
338340
339341Although the Angular application that this guide shows you how to build is simple,
340342when you build more complex Angular applications, testing becomes a crucial part
0 commit comments