Skip to content

Commit b39fd5f

Browse files
petebacondarwinatscott
authored andcommitted
docs: update getting started tutorial to use StackBlitz web-containers (angular#44085)
Previous commits changed the docs to use web-container versions for StackBlitz examples. This commit updates the content of the tutorial to match. Fixes angular#44079 PR Close angular#44085
1 parent dc7e5a1 commit b39fd5f

File tree

7 files changed

+54
-25
lines changed

7 files changed

+54
-25
lines changed
9.8 KB
Loading
11.3 KB
Loading
20 KB
Loading

aio/content/start/index.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ To save your work:
5353
1. Fork the project you generated.
5454
1. Save periodically.
5555

56+
<div class="lightbox">
57+
<img src="generated/images/guide/start/fork-the-project.png" alt="Fork the project">
58+
</div>
59+
5660
In StackBlitz, the preview pane on the right shows the starting state of the example application.
5761
The preview features two areas:
5862

@@ -162,13 +166,20 @@ The alert checks the product's price, and, if the price is greater than $700, di
162166

163167
This section walks you through creating a child component, `ProductAlertsComponent` that can receive data from its parent component, `ProductListComponent`.
164168

165-
1. Right click on the `app` folder and use the `Angular Generator` to generate a new component named `product-alerts`.
169+
1. Click on the plus sign above the current terminal to create a new terminal to run the command to generate the component.
166170

167171
<div class="lightbox">
168-
<img src="http://github.com/generated/images/guide/start/%3Cspan%20class="x x-first x-last">generate-component.png" alt="StackBlitz command to generate component">
172+
<img src="http://github.com/generated/images/guide/start/%3Cspan%20class="x x-first x-last">create-new-terminal.png" alt="StackBlitz command to generate component">
169173
</div>
170174

171-
The generator creates starter files for the three parts of the component:
175+
1. In the new terminal, generate a new component named `product-alerts` by running the following command.
176+
177+
```sh
178+
ng generate component product-alerts
179+
```
180+
181+
The generator creates starter files for the three parts of the component:
182+
172183
* `product-alerts.component.ts`
173184
* `product-alerts.component.html`
174185
* `product-alerts.component.css`
@@ -199,11 +210,11 @@ This section walks you through creating a child component, `ProductAlertsCompone
199210

200211
<code-example header="src/app/product-alerts/product-alerts.component.html" path="getting-started/src/app/product-alerts/product-alerts.component.1.html"></code-example>
201212

202-
1. To make `ProductAlertsComponent` available to other components in the application, add it to `AppModule`'s declarations in `app.module.ts`.
213+
1. The generator automatically added the `ProductAlertsComponent` to the `AppModule` to make it available to other components in the application.
203214

204215
<code-example header="src/app/app.module.ts" path="getting-started/src/app/app.module.ts" region="declare-product-alerts"></code-example>
205216

206-
1. Finally, to display `ProductAlertsComponent` as a child of `ProductListComponent`, add the selector, `<app-product-alerts>` to `product-list.component.html`.
217+
1. Finally, to display `ProductAlertsComponent` as a child of `ProductListComponent`, add the `<app-product-alerts>` element to `product-list.component.html`.
207218
Pass the current product as input to the component using property binding.
208219

209220
<code-example header="src/app/product-list/product-list.component.html" path="getting-started/src/app/product-list/product-list.component.5.html" region="app-product-alerts"></code-example>

aio/content/start/start-data.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ This section walks you through adding a **Buy** button and setting up a cart ser
2525

2626
### Define a cart service
2727

28-
1. To generate a cart service, right click on the `app` folder, choose **Angular Generator**, and choose **Service**.
29-
Name the new service `cart`.
28+
This section walks you through creating the `CartService` that tracks products added to shopping cart.
3029

31-
<code-example header="src/app/cart.service.ts" path="getting-started/src/app/cart.service.1.ts"></code-example>
30+
1. In the terminal generate a new `cart` service by running the following command:
3231

33-
1. Import the `Product` interface from `./products.js`.
34-
1. In the `CartService` class, define an `items` property to store the array of the current products in the cart.
32+
```sh
33+
ng generate service cart
34+
```
35+
36+
1. Import the `Product` interface from `./products.ts` into the `cart.service.ts` file, and in the `CartService` class, define an `items` property to store the array of the current products in the cart.
3537

3638
<code-example path="getting-started/src/app/cart.service.ts" header="src/app/cart.service.ts" region="props"></code-example>
3739

@@ -99,13 +101,19 @@ For customers to see their cart, you can create the cart view in two steps:
99101
100102
To create the cart view, follow the same steps you did to create the `ProductDetailsComponent` and configure routing for the new component.
101103
102-
1. Generate a cart component named `cart` by right-clicking the `app` folder, choosing **Angular Generator**, and **Component**.
104+
1. Generate a new component named `cart` in the terminal by running the following command:
105+
106+
```sh
107+
ng generate component cart
108+
```
109+
110+
This command will generate the `cart.component.ts` file and it associated template and styles files.
103111

104112
<code-example header="src/app/cart/cart.component.ts" path="getting-started/src/app/cart/cart.component.1.ts"></code-example>
105113

106114
StackBlitz also generates an `ngOnInit()` by default in components. You can ignore the `CartComponent` `ngOnInit()` for this tutorial.
107115
108-
1. Ensure that the newly created `CartComponent` is added to the module's `declarations` in `app.module.ts`.
116+
1. Note that the newly created `CartComponent` is added to the module's `declarations` in `app.module.ts`.
109117
110118
<code-example header="src/app/app.module.ts" path="getting-started/src/app/app.module.ts" region="declare-cart">
111119
</code-example>
@@ -230,7 +238,13 @@ For more information about Angular's `HttpClient`, see the [Client-Server Intera
230238
231239
Now that you've configured your application to retrieve shipping data, you can create a place to render that data.
232240
233-
1. Generate a new component named `shipping` by right-clicking the `app` folder, choosing **Angular Generator**, and selecting **Component**.
241+
1. Generate a cart component named `shipping` in the terminal by running the following command:
242+
243+
```sh
244+
ng generate component shipping
245+
```
246+
247+
This command will generate the `shipping.component.ts` file and it associated template and styles files.
234248

235249
<code-example header="src/app/shipping/shipping.component.ts" path="getting-started/src/app/shipping/shipping.component.1.ts"></code-example>
236250

@@ -240,7 +254,7 @@ Now that you've configured your application to retrieve shipping data, you can c
240254
<code-example header="src/app/app.module.ts" path="getting-started/src/app/app.module.ts" region="shipping-route"></code-example>
241255

242256
There's no link to the new shipping component yet, but you can see its template in the preview pane by entering the URL its route specifies.
243-
The URL has the pattern: `https://getting-started.stackblitz.io/shipping` where the `getting-started.stackblitz.io` part may be different for your StackBlitz project.
257+
The URL has the pattern: `https://angular-ynqttp--4200.local.webcontainer.io/shipping` where the `angular-ynqttp--4200.local.webcontainer.io` part may be different for your StackBlitz project.
244258
245259
### Configuring the `ShippingComponent` to use `CartService`
246260

aio/content/start/start-deployment.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,26 @@ A best practice is to run your project locally before you deploy it. To run your
2020

2121
## Running your application locally
2222

23-
1. Download the source code from your StackBlitz project by clicking the `Download Project` icon in the left menu, across from `Project`, to download your files.
23+
1. Download the source code from your StackBlitz project by clicking the `Download Project` icon in the left menu, across from `Project`, to download your project as a zip archive.
2424

25-
1. Create a new Angular CLI workspace using the [`ng new`](cli/new "CLI ng new command reference") command, where `my-project-name` is what you would like to call your project:
25+
<div class="lightbox">
26+
<img src="generated/images/guide/start/download-project.png" alt="Download the stackblitz project">
27+
</div>
28+
29+
30+
1. Unzip the archive change directory to the newly created project. For example:
2631

2732
```sh
28-
ng new my-project-name
33+
cd angular-ynqttp
2934
```
3035

31-
This command displays a series of configuration prompts. For this tutorial, accept the default settings for each prompt.
32-
33-
1. In your newly CLI-generated application, replace the `/src` folder with the `/src` folder from your `StackBlitz` download.
34-
3536
1. Use the following CLI command to run your application locally:
3637

3738
```sh
3839
ng serve
3940
```
4041

41-
1. To see your application in the browser, go to http://localhost:4200/.
42+
1. To see your application in the browser, go to http://localhost:4200/.
4243
If the default port 4200 is not available, you can specify another port with the port flag as in the following example:
4344

4445
```sh

aio/content/start/start-routing.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ The application already uses the Angular `Router` to navigate to the `ProductLis
1818
This section shows you how to define a route to show individual product details.
1919

2020
1. Generate a new component for product details.
21-
In the file list, right-click the `app` folder, choose `Angular Generator` and `Component`.
22-
Name the component `product-details`.
21+
In the terminal generate a new `product-details` component by running the following command:
2322

24-
1. In `app.module.ts`, add a route for product details, with a `path` of `products/:productId` and `ProductDetailsComponent` for the `component`, include `ProductDetailsComponent` in `AppModule`'s declarations.
23+
```sh
24+
ng generate component product-details
25+
```
26+
27+
1. In `app.module.ts`, add a route for product details, with a `path` of `products/:productId` and `ProductDetailsComponent` for the `component`.
2528

2629
<code-example header="src/app/app.module.ts" path="getting-started/src/app/app.module.ts" region="product-details-route">
2730
</code-example>

0 commit comments

Comments
 (0)