Skip to content

Commit c1915f1

Browse files
bencodezenatscott
authored andcommitted
docs: fix visible code snippets in first-app tutorial (angular#55742)
PR Close angular#55742
1 parent c001286 commit c1915f1

File tree

13 files changed

+33
-32
lines changed

13 files changed

+33
-32
lines changed

adev/src/content/tutorials/first-app/steps/02-HomeComponent/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ In the **Edit** pane of your IDE:
7070

7171
1. In `app.component.ts`, in `@Component`, update the `imports` array property and add `HomeComponent`.
7272

73-
<docs-code header="Replace in src/app/app.component.ts" path="adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/app/app.component.ts" visibleLines="[7,9]"/>
73+
<docs-code header="Replace in src/app/app.component.ts" path="adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/app/app.component.ts" visibleLines="[7]"/>
7474

7575
1. In `app.component.ts`, in `@Component`, update the `template` property to include the following HTML code.
7676

77-
<docs-code header="Replace in src/app/app.component.ts" path="adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/app/app.component.ts" visibleLines="[10,19]"/>
77+
<docs-code header="Replace in src/app/app.component.ts" path="adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/app/app.component.ts" visibleLines="[8,17]"/>
7878

7979
1. Save your changes to `app.component.ts`.
8080
1. If `ng serve` is running, the app should update.
@@ -87,6 +87,7 @@ In the **Edit** pane of your IDE:
8787
</docs-step>
8888

8989
<docs-step title="Add features to `HomeComponent`">
90+
9091
In this step you add features to `HomeComponent`.
9192

9293
In the previous step, you added the default `HomeComponent` to your app's template so its default HTML appeared in the app.
@@ -99,7 +100,7 @@ In the **Edit** pane of your IDE:
99100
1. In the `first-app` directory, open `home.component.ts` in the editor.
100101
1. In `home.component.ts`, in `@Component`, update the `template` property with this code.
101102

102-
<docs-code header="Replace in src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/app/home/home.component.ts" visibleLines="[10,17]"/>
103+
<docs-code header="Replace in src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/app/home/home.component.ts" visibleLines="[8,15]"/>
103104

104105
1. Next, open `home.component.css` in the editor and update the content with these styles.
105106

adev/src/content/tutorials/first-app/steps/03-HousingLocation/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ In the **Edit** pane of your IDE:
5151

5252
1. Next update the `imports` property of the `@Component` metadata by adding `HousingLocationComponent` to the array.
5353

54-
<docs-code header="Add HousingLocationComponent to imports array in src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/home/home.component.ts" visibleLines="[7,10]"/>
54+
<docs-code header="Add HousingLocationComponent to imports array in src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/home/home.component.ts" visibleLines="[7]"/>
5555

5656
1. Now the component is ready for use in the template for the `HomeComponent`. Update the `template` property of the `@Component` metadata to include a reference to the `<app-housing-location>` tag.
5757

58-
<docs-code header="Add housing location to the component template in src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/home/home.component.ts" visibleLines="[11,21]"/>
58+
<docs-code header="Add housing location to the component template in src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/home/home.component.ts" visibleLines="[8,18]"/>
5959

6060
</docs-step>
6161

adev/src/content/tutorials/first-app/steps/04-interfaces/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ This step adds the properties to the interface that your app needs to represent
4848
1. In the **Edit** pane of your IDE, open the `src/app/housinglocation.ts` file.
4949
1. In `housinglocation.ts`, replace the default content with the following code to make your new interface to match this example.
5050

51-
<docs-code header="Update src/app/housinglocation.ts to match this code" path="adev/src/content/tutorials/first-app/steps/05-inputs/src/app/housinglocation.ts"/>
51+
<docs-code header="Update src/app/housinglocation.ts to match this code" path="adev/src/content/tutorials/first-app/steps/05-inputs/src/app/housinglocation.ts" visibleLines="[1,10]" />
5252

5353
1. Save your changes and confirm the app does not display any errors. Correct any errors before you continue to the next step.
5454

@@ -70,11 +70,11 @@ There are a few more lessons to complete before that happens.
7070

7171
1. In `src/app/home/home.component.ts`, replace the empty `export class HomeComponent {}` definition with this code to create a single instance of the new interface in the component.
7272

73-
<docs-code header="Add sample data to src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/05-inputs/src/app/home/home.component.ts" visibleLines="[27,38]"/>
73+
<docs-code header="Add sample data to src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/05-inputs/src/app/home/home.component.ts" visibleLines="[23,36]"/>
7474

7575
1. Confirm that your `home.component.ts` file matches like this example.
7676

77-
<docs-code header="src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/05-inputs/src/app/home/home.component.ts"/>
77+
<docs-code header="src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/05-inputs/src/app/home/home.component.ts" visibleLines="[1,36]" />
7878

7979
By adding the `housingLocation` property of type `HousingLocation` to the `HomeComponent` class, we're able to confirm that the data matches the description of the interface. If the data didn't satisfy the description of the interface, the IDE has enough information to give us helpful errors.
8080

adev/src/content/tutorials/first-app/steps/05-inputs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ In the code editor:
3333
<docs-step title="Add the Input property">
3434
1. In the same file, add a property called `housingLocation` of type `HousingLocation` to the `HousingLocationComponent` class. Add an `!` after the property name and prefix it with the `@Input()` decorator:
3535

36-
<docs-code header="Import HousingLocationComponent and Input in src/app/housing-location/housing-location.component.ts" path="adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/housing-location/housing-location.component.ts" visibleLines="[16,18]"/>
36+
<docs-code header="Import HousingLocationComponent and Input in src/app/housing-location/housing-location.component.ts" path="adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/housing-location/housing-location.component.ts" visibleLines="[13,15]"/>
3737

3838
You have to add the `!` because the input is expecting the value to be passed. In this case, there is no default value. In our example application case we know that the value will be passed in - this is by design. The exclamation point is called the non-null assertion operator and it tells the TypeScript compiler that the value of this property won't be null or undefined.
3939

adev/src/content/tutorials/first-app/steps/06-property-binding/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ In the code editor:
2626

2727
1. Navigate to `src/app/home/home.component.ts`
2828
1. In the template property of the `@Component` decorator, update the code to match the code below:
29-
<docs-code header="Add housingLocation property binding" path="adev/src/content/tutorials/first-app/steps/07-dynamic-template-values/src/app/home/home.component.ts" visibleLines="[21]"/>
29+
<docs-code header="Add housingLocation property binding" path="adev/src/content/tutorials/first-app/steps/07-dynamic-template-values/src/app/home/home.component.ts" visibleLines="[17,19]"/>
3030

3131
When adding a property binding to a component tag, we use the `[attribute] = "value"` syntax to notify Angular that the assigned value should be treated as a property from the component class and not a string value.
3232

adev/src/content/tutorials/first-app/steps/07-dynamic-template-values/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ In the code editor:
2727
1. Navigate to `src/app/housing-location/housing-location.component.ts`
2828
1. In the template property of the `@Component` decorator, replace the existing HTML markup with the following code:
2929

30-
<docs-code header="Update HousingLocationComponent template" path="adev/src/content/tutorials/first-app/steps/08-ngFor/src/app/housing-location/housing-location.component.ts" visibleLines="[9,15]"/>
30+
<docs-code header="Update HousingLocationComponent template" path="adev/src/content/tutorials/first-app/steps/08-ngFor/src/app/housing-location/housing-location.component.ts" visibleLines="[9,20]"/>
3131

3232
In this updated template code you have used property binding to bind the `housingLocation.photo` to the `src` attribute. The `alt` attribute uses interpolation to give more context to the alt text of the image.
3333

adev/src/content/tutorials/first-app/steps/08-ngFor/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ In the `HomeComponent` there is only a single housing location. In this step, yo
2525

2626
1. In `src/app/home/home.component.ts`, remove the `housingLocation` property from the `HomeComponent` class.
2727
1. Update the `HomeComponent` class to have a property called `housingLocationList`. Update your code to match the following code:
28-
<docs-code header="Add housingLocationList property" path="adev/src/content/tutorials/first-app/steps/09-services/src/app/home/home.component.ts" visibleLines="31-136"/>
28+
<docs-code header="Add housingLocationList property" path="adev/src/content/tutorials/first-app/steps/09-services/src/app/home/home.component.ts" visibleLines="26-131"/>
2929

3030
IMPORTANT: Do not remove the `@Component` decorator, you will update that code in an upcoming step.
3131

@@ -35,7 +35,7 @@ In the `HomeComponent` there is only a single housing location. In this step, yo
3535
Now the app has a dataset that you can use to display the entries in the browser using the `ngFor` directive.
3636

3737
1. Update the `<app-housing-location>` tag in the template code to this:
38-
<docs-code header="Add ngFor to HomeComponent template" path="adev/src/content/tutorials/first-app/steps/09-services/src/app/home/home.component.ts" visibleLines="[21,24]"/>
38+
<docs-code header="Add ngFor to HomeComponent template" path="adev/src/content/tutorials/first-app/steps/09-services/src/app/home/home.component.ts" visibleLines="[17,22]"/>
3939

4040
Note, in the code `[housingLocation] = "housingLocation"` the `housingLocation` value now refers to the variable used in the `ngFor` directive. Before this change, it referred to the property on the `HomeComponent` class.
4141

adev/src/content/tutorials/first-app/steps/09-services/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ In the **Edit** pane of your IDE, in `src/app/home/home.component.ts`:
8787

8888
1. In `HomeComponent`, add the following code to inject the new service and initialize the data for the app. The `constructor` is the first function that runs when this component is created. The code in the `constructor` will assign the `housingLocationList` the value returned from the call to `getAllHousingLocations`.
8989

90-
<docs-code header="Initialize data from service in src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/10-routing/src/app/home/home.component.ts" visibleLines="[31,36]"/>
90+
<docs-code header="Initialize data from service in src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/10-routing/src/app/home/home.component.ts" visibleLines="[28,32]"/>
9191

9292
1. Save the changes to `src/app/home/home.component.ts` and confirm your app builds without error.
9393
Correct any errors before you continue to the next step.

adev/src/content/tutorials/first-app/steps/10-routing/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ In this lesson, you will enable routing in your application to navigate to the d
4949

5050
1. Add `RouterModule` to the `@Component` metadata imports
5151

52-
<docs-code header="Import RouterModule in src/app/app.component.ts" path="adev/src/content/tutorials/first-app/steps/11-details-page/src/app/app.component.ts" visibleLines="[9,12]"/>
52+
<docs-code header="Import RouterModule in src/app/app.component.ts" path="adev/src/content/tutorials/first-app/steps/11-details-page/src/app/app.component.ts" visibleLines="[7]"/>
5353

5454
1. In the `template` property, replace the `<app-home></app-home>` tag with the `<router-outlet>` directive and add a link back to the home page. Your code should match this code:
5555

56-
<docs-code header="Add router-outlet in src/app/app.component.ts" path="adev/src/content/tutorials/first-app/steps/11-details-page/src/app/app.component.ts" visibleLines="[13,24]"/>
56+
<docs-code header="Add router-outlet in src/app/app.component.ts" path="adev/src/content/tutorials/first-app/steps/11-details-page/src/app/app.component.ts" visibleLines="[8,18]"/>
5757

5858
</docs-step>
5959

adev/src/content/tutorials/first-app/steps/11-details-page/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ In this case, `:id` is dynamic and will change based on how the route is request
2929

3030
1. In `src/app/housing-location/housing-location.component.ts`, add an anchor tag to the `section` element and include the `routerLink` directive:
3131

32-
<docs-code header="Add anchor with a routerLink directive to housing-location.component.ts" path="adev/src/content/tutorials/first-app/steps/12-forms/src/app/housing-location/housing-location.component.ts" visibleLines="[13,20]"/>
32+
<docs-code header="Add anchor with a routerLink directive to housing-location.component.ts" path="adev/src/content/tutorials/first-app/steps/12-forms/src/app/housing-location/housing-location.component.ts" visibleLines="[20]"/>
3333

3434
The `routerLink` directive enables Angular's router to create dynamic links in the application. The value assigned to the `routerLink` is an array with two entries: the static portion of the path and the dynamic data.
3535

@@ -53,7 +53,7 @@ In this step, you will get the route parameter in the `DetailsComponent`. Curren
5353
template: `<p>details works! {{ housingLocationId }}</p>`,
5454
</docs-code>
5555

56-
1. Update the body of the `DetailsComponent` with the following code:
56+
1. Update the body of the `DetailsComponent` class with the following code:
5757

5858
<docs-code language="javascript">
5959
export class DetailsComponent {
@@ -79,13 +79,13 @@ To access the data you will add a call to the `HousingService`.
7979

8080
1. Update the template code to match the following code:
8181

82-
<docs-code header="Update the DetailsComponent template in src/app/details/details.component.ts" path="adev/src/content/tutorials/first-app/steps/12-forms/src/app/details/details.component.ts" visibleLines="[11,28]"/>
82+
<docs-code header="Update the DetailsComponent template in src/app/details/details.component.ts" path="adev/src/content/tutorials/first-app/steps/12-forms/src/app/details/details.component.ts" visibleLines="[11,32]"/>
8383

8484
Notice that the `housingLocation` properties are being accessed with the optional chaining operator `?`. This ensures that if the `housingLocation` value is null or undefined the application doesn't crash.
8585

8686
1. Update the body of the `DetailsComponent` class to match the following code:
8787

88-
<docs-code header="Update the DetailsComponent class in src/app/details/details.component.ts" path="adev/src/content/tutorials/first-app/steps/12-forms/src/app/details/details.component.ts" visibleLines="[31,42]"/>
88+
<docs-code header="Update the DetailsComponent class in src/app/details/details.component.ts" path="adev/src/content/tutorials/first-app/steps/12-forms/src/app/details/details.component.ts" visibleLines="[35,44]"/>
8989

9090
Now the component has the code to display the correct information based on the selected housing location. The `constructor` now includes a call to the `HousingService` to pass the route parameter as an argument to the `getHousingLocationById` service function.
9191

@@ -106,7 +106,7 @@ In a previous lesson you updated the `AppComponent` template to include a `route
106106

107107
1. Confirm that your code matches the following:
108108

109-
<docs-code header="Add routerLink to AppComponent" path="adev/src/content/tutorials/first-app/steps/12-forms/src/app/app.component.ts" visibleLines="[13,24]"/>
109+
<docs-code header="Add routerLink to AppComponent" path="adev/src/content/tutorials/first-app/steps/12-forms/src/app/app.component.ts" visibleLines="[8,20]"/>
110110

111111
Your code may already be up-to-date but confirm to be sure.
112112
</docs-step>

0 commit comments

Comments
 (0)