diff --git a/adev/src/content/tutorials/first-app/steps/05-inputs/README.md b/adev/src/content/tutorials/first-app/steps/05-inputs/README.md index ffc276f9361..e15c0e15fe1 100644 --- a/adev/src/content/tutorials/first-app/steps/05-inputs/README.md +++ b/adev/src/content/tutorials/first-app/steps/05-inputs/README.md @@ -21,9 +21,9 @@ Learn more in the [Accepting data with input properties](guide/components/inputs -In the code editor, import the `input` helper method from `@angular/core` and the `HousingLocation` component. +In the code editor, import the `input` helper method from `@angular/core` into the `HousingLocation` component. - + @@ -32,14 +32,14 @@ Add a required property called `housingLocation` and initialize it using `input. -You have to invoked the `required` method on `input` to indicate that the parent component must provide a value. In our example application, we know this value will always be passed in — this is by design. The `.required()` call ensures that the TypeScript compiler enforces this and treats the property as non-nullable when this component is used in a template. +You have to invoke the `required` method on `input` to indicate that the parent component must provide a value. In our example application, we know this value will always be passed in — this is by design. The `.required()` call ensures that the TypeScript compiler enforces this and treats the property as non-nullable when this component is used in a template. Send the `housingLocation` value from the `Home` component to the `housingLocation` property of the HousingLocation component. - + diff --git a/adev/src/content/tutorials/first-app/steps/07-dynamic-template-values/README.md b/adev/src/content/tutorials/first-app/steps/07-dynamic-template-values/README.md index 0eded217b91..e9d294a562f 100644 --- a/adev/src/content/tutorials/first-app/steps/07-dynamic-template-values/README.md +++ b/adev/src/content/tutorials/first-app/steps/07-dynamic-template-values/README.md @@ -11,9 +11,9 @@ This tutorial lesson demonstrates how to add interpolation to Angular templates ## Conceptual preview of interpolation -In this step you will display values (properties and `Input` values) in a template using interpolation. +In this step you will display values read from `input` properties in a template using interpolation. -Using the `{{ expression }}` in Angular templates, you can render values from properties, `Inputs` and valid JavaScript expressions. +Using the `{{ expression }}` in Angular templates, you can render values from properties, `inputs`, and valid JavaScript expressions. For a more in depth explanation, please refer to the [Displaying values with interpolation](guide/templates/binding#render-dynamic-text-with-text-interpolation) guide. @@ -27,7 +27,7 @@ In the code editor: 1. Navigate to `src/app/housing-location/housing-location.ts` 1. In the template property of the `@Component` decorator, replace the existing HTML markup with the following code: - + 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. diff --git a/adev/src/content/tutorials/first-app/steps/08-ngFor/README.md b/adev/src/content/tutorials/first-app/steps/08-ngFor/README.md index d9bcdb77c54..9ecc63e52bc 100644 --- a/adev/src/content/tutorials/first-app/steps/08-ngFor/README.md +++ b/adev/src/content/tutorials/first-app/steps/08-ngFor/README.md @@ -27,7 +27,7 @@ In the `Home` there is only a single housing location. In this step, you will ad 1. In `src/app/home/home.ts`, remove the `housingLocation` property from the `Home` class. 1. Update the `Home` class to have a property called `housingLocationList`. Update your code to match the following code: - + IMPORTANT: Do not remove the `@Component` decorator, you will update that code in an upcoming step. @@ -37,7 +37,7 @@ In the `Home` there is only a single housing location. In this step, you will ad Now the app has a dataset that you can use to display the entries in the browser using the `@for` block. 1. Update the `` tag in the template code to this: - + Note, in the code `[housingLocation] = "housingLocation"` the `housingLocation` value now refers to the variable used in the `@for` block. Before this change, it referred to the property on the `Home` class. diff --git a/adev/src/content/tutorials/first-app/steps/11-details-page/README.md b/adev/src/content/tutorials/first-app/steps/11-details-page/README.md index 775b606c7af..09b4790c6f5 100644 --- a/adev/src/content/tutorials/first-app/steps/11-details-page/README.md +++ b/adev/src/content/tutorials/first-app/steps/11-details-page/README.md @@ -29,7 +29,7 @@ In this case, `:id` is dynamic and will change based on how the route is request 1. In `src/app/housing-location/housing-location.ts`, add an anchor tag to the `section` element and include the `routerLink` directive: - + 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. @@ -57,11 +57,11 @@ In this step, you will get the route parameter in the `Details`. Currently, the export class Details { - route: ActivatedRoute = inject(ActivatedRoute); - housingLocationId = -1; - constructor() { - this.housingLocationId = Number(this.route.snapshot.params['id']); - } + route: ActivatedRoute = inject(ActivatedRoute); + housingLocationId = -1; + constructor() { + this.housingLocationId = Number(this.route.snapshot.params['id']); + } } @@ -93,7 +93,10 @@ To access the data you will add a call to the `HousingService`. -1. Save your changes. + and save your changes + +1. In `Details` use the just created `details.css` file as the source for the styles: + 1. In the browser refresh the page and confirm that when you click on the "Learn More" link for a given housing location the details page displays the correct information based on the data for that selected item. @@ -101,14 +104,14 @@ To access the data you will add a call to the `HousingService`. - + In a previous lesson you updated the `App` template to include a `routerLink`. Adding that code updated your app to enable navigation back to the `Home` whenever the logo is clicked. 1. Confirm that your code matches the following: - + - Your code may already be up-to-date but confirm to be sure. + Your code should already be up-to-date but confirm to be sure. diff --git a/adev/src/content/tutorials/first-app/steps/13-search/README.md b/adev/src/content/tutorials/first-app/steps/13-search/README.md index fd5e0687eed..d9726574356 100644 --- a/adev/src/content/tutorials/first-app/steps/13-search/README.md +++ b/adev/src/content/tutorials/first-app/steps/13-search/README.md @@ -20,13 +20,13 @@ In this step, you'll update the `Home` class to store data in a new array proper 1. In `src/app/home/home.ts`, add new property to the class called `filteredLocationList`. - + The `filteredLocationList` hold the values that match the search criteria entered by the user. 1. The `filteredLocationList` should contain the total set of housing locations values by default when the page loads. Update the `constructor` for the `Home` to set the value. - + @@ -35,27 +35,18 @@ The `Home` already contains an input field that you will use to capture input fr 1. Update the `Home` template to include a template variable in the `input` element called `#filter`. - - - - + This example uses a [template reference variable](guide/templates) to get access to the `input` element as its value. 1. Next, update the component template to attach an event handler to the "Search" button. - - - + By binding to the `click` event on the `button` element, you are able to call the `filterResults` function. The argument to the function is the `value` property of the `filter` template variable. Specifically, the `.value` property from the `input` HTML element. -1. The last template update is to the `ngFor` directive. Update the `ngFor` value to iterate over values from the `filteredLocationList` array. +1. The last template update is to the `@for` directive. Update the `@for` to iterate over values from the `filteredLocationList` array. - -@for(housingLocation of housingLocationList; track $index) { - -} - + diff --git a/adev/src/content/tutorials/first-app/steps/14-http/README.md b/adev/src/content/tutorials/first-app/steps/14-http/README.md index 9c0502f350b..c9bd6e91195 100644 --- a/adev/src/content/tutorials/first-app/steps/14-http/README.md +++ b/adev/src/content/tutorials/first-app/steps/14-http/README.md @@ -26,110 +26,110 @@ JSON Server is an open source tool used to create mock REST APIs. You'll use it 1. Open `db.json` and copy the following code into the file + { + "locations": [ { - "locations": [ - { - "id": 0, - "name": "Acme Fresh Start Housing", - "city": "Chicago", - "state": "IL", - "photo": "https://angular.dev/assets/images/tutorials/common/bernard-hermant-CLKGGwIBTaY-unsplash.jpg", - "availableUnits": 4, - "wifi": true, - "laundry": true - }, - { - "id": 1, - "name": "A113 Transitional Housing", - "city": "Santa Monica", - "state": "CA", - "photo": "https://angular.dev/assets/images/tutorials/common/brandon-griggs-wR11KBaB86U-unsplash.jpg", - "availableUnits": 0, - "wifi": false, - "laundry": true - }, - { - "id": 2, - "name": "Warm Beds Housing Support", - "city": "Juneau", - "state": "AK", - "photo": "https://angular.dev/assets/images/tutorials/common/i-do-nothing-but-love-lAyXdl1-Wmc-unsplash.jpg", - "availableUnits": 1, - "wifi": false, - "laundry": false - }, - { - "id": 3, - "name": "Homesteady Housing", - "city": "Chicago", - "state": "IL", - "photo": "https://angular.dev/assets/images/tutorials/common/ian-macdonald-W8z6aiwfi1E-unsplash.jpg", - "availableUnits": 1, - "wifi": true, - "laundry": false - }, - { - "id": 4, - "name": "Happy Homes Group", - "city": "Gary", - "state": "IN", - "photo": "https://angular.dev/assets/images/tutorials/common/krzysztof-hepner-978RAXoXnH4-unsplash.jpg", - "availableUnits": 1, - "wifi": true, - "laundry": false - }, - { - "id": 5, - "name": "Hopeful Apartment Group", - "city": "Oakland", - "state": "CA", - "photo": "https://angular.dev/assets/images/tutorials/common/r-architecture-JvQ0Q5IkeMM-unsplash.jpg", - "availableUnits": 2, - "wifi": true, - "laundry": true - }, - { - "id": 6, - "name": "Seriously Safe Towns", - "city": "Oakland", - "state": "CA", - "photo": "https://angular.dev/assets/images/tutorials/common/phil-hearing-IYfp2Ixe9nM-unsplash.jpg", - "availableUnits": 5, - "wifi": true, - "laundry": true - }, - { - "id": 7, - "name": "Hopeful Housing Solutions", - "city": "Oakland", - "state": "CA", - "photo": "https://angular.dev/assets/images/tutorials/common/r-architecture-GGupkreKwxA-unsplash.jpg", - "availableUnits": 2, - "wifi": true, - "laundry": true - }, - { - "id": 8, - "name": "Seriously Safe Towns", - "city": "Oakland", - "state": "CA", - "photo": "https://angular.dev/assets/images/tutorials/common/saru-robert-9rP3mxf8qWI-unsplash.jpg", - "availableUnits": 10, - "wifi": false, - "laundry": false - }, - { - "id": 9, - "name": "Capital Safe Towns", - "city": "Portland", - "state": "OR", - "photo": "https://angular.dev/assets/images/tutorials/common/webaliser-_TPTXZd9mOo-unsplash.jpg", - "availableUnits": 6, - "wifi": true, - "laundry": true - } - ] + "id": 0, + "name": "Acme Fresh Start Housing", + "city": "Chicago", + "state": "IL", + "photo": "https://angular.dev/assets/images/tutorials/common/bernard-hermant-CLKGGwIBTaY-unsplash.jpg", + "availableUnits": 4, + "wifi": true, + "laundry": true + }, + { + "id": 1, + "name": "A113 Transitional Housing", + "city": "Santa Monica", + "state": "CA", + "photo": "https://angular.dev/assets/images/tutorials/common/brandon-griggs-wR11KBaB86U-unsplash.jpg", + "availableUnits": 0, + "wifi": false, + "laundry": true + }, + { + "id": 2, + "name": "Warm Beds Housing Support", + "city": "Juneau", + "state": "AK", + "photo": "https://angular.dev/assets/images/tutorials/common/i-do-nothing-but-love-lAyXdl1-Wmc-unsplash.jpg", + "availableUnits": 1, + "wifi": false, + "laundry": false + }, + { + "id": 3, + "name": "Homesteady Housing", + "city": "Chicago", + "state": "IL", + "photo": "https://angular.dev/assets/images/tutorials/common/ian-macdonald-W8z6aiwfi1E-unsplash.jpg", + "availableUnits": 1, + "wifi": true, + "laundry": false + }, + { + "id": 4, + "name": "Happy Homes Group", + "city": "Gary", + "state": "IN", + "photo": "https://angular.dev/assets/images/tutorials/common/krzysztof-hepner-978RAXoXnH4-unsplash.jpg", + "availableUnits": 1, + "wifi": true, + "laundry": false + }, + { + "id": 5, + "name": "Hopeful Apartment Group", + "city": "Oakland", + "state": "CA", + "photo": "https://angular.dev/assets/images/tutorials/common/r-architecture-JvQ0Q5IkeMM-unsplash.jpg", + "availableUnits": 2, + "wifi": true, + "laundry": true + }, + { + "id": 6, + "name": "Seriously Safe Towns", + "city": "Oakland", + "state": "CA", + "photo": "https://angular.dev/assets/images/tutorials/common/phil-hearing-IYfp2Ixe9nM-unsplash.jpg", + "availableUnits": 5, + "wifi": true, + "laundry": true + }, + { + "id": 7, + "name": "Hopeful Housing Solutions", + "city": "Oakland", + "state": "CA", + "photo": "https://angular.dev/assets/images/tutorials/common/r-architecture-GGupkreKwxA-unsplash.jpg", + "availableUnits": 2, + "wifi": true, + "laundry": true + }, + { + "id": 8, + "name": "Seriously Safe Towns", + "city": "Oakland", + "state": "CA", + "photo": "https://angular.dev/assets/images/tutorials/common/saru-robert-9rP3mxf8qWI-unsplash.jpg", + "availableUnits": 10, + "wifi": false, + "laundry": false + }, + { + "id": 9, + "name": "Capital Safe Towns", + "city": "Portland", + "state": "OR", + "photo": "https://angular.dev/assets/images/tutorials/common/webaliser-_TPTXZd9mOo-unsplash.jpg", + "availableUnits": 6, + "wifi": true, + "laundry": true } + ] + } 1. Save this file. @@ -150,33 +150,31 @@ The data source has been configured, the next step is to update your web app to 1. In `src/app/housing.service.ts`, make the following changes: - 1. Update the code to remove `housingLocationList` property and the array containing the data. +1. Update the code to remove `housingLocationList` property and the array containing the data, as well as the `baseUrl` property. - 1. Add a string property called `url` and set its value to `'http://localhost:3000/locations'` +1. Add a string property called `url` and set its value to `'http://localhost:3000/locations'` - - url = 'http://localhost:3000/locations'; - + - This code will result in errors in the rest of the file because it depends on the `housingLocationList` property. We're going to update the service methods next. + This code will result in errors in the rest of the file because it depends on the `housingLocationList` property. We're going to update the service methods next. - 1. Update the `getAllHousingLocations` function to make a call to the web server you configured. +1. Update the `getAllHousingLocations` function to make a call to the web server you configured. - + - The code now uses asynchronous code to make a **GET** request over HTTP. + The code now uses asynchronous code to make a **GET** request over HTTP. - HELPFUL: For this example, the code uses `fetch`. For more advanced use cases consider using `HttpClient` provided by Angular. + HELPFUL: For this example, the code uses `fetch`. For more advanced use cases consider using `HttpClient` provided by Angular. - 1. Update the `getHousingLocationsById` function to make a call to the web server you configured. - - HELPFUL: Notice the `fetch` method has been updated to _query_ the data for location with a matching `id` property value. See [URL Search Parameter](https://developer.mozilla.org/en-US/docs/Web/API/URL/search) for more information. +1. Update the `getHousingLocationsById` function to make a call to the web server you configured. - + HELPFUL: Notice the `fetch` method has been updated to _query_ the data for location with a matching `id` property value. See [URL Search Parameter](https://developer.mozilla.org/en-US/docs/Web/API/URL/search) for more information. - 1. Once all the updates are complete, your updated service should match the following code. + - +1. Once all the updates are complete, your updated service should match the following code. + + @@ -185,12 +183,11 @@ The server is now reading data from the HTTP request but the components that rel 1. In `src/app/home/home.ts`, update the `constructor` to use the new asynchronous version of the `getAllHousingLocations` method. - + 1. In `src/app/details/details.ts`, update the `constructor` to use the new asynchronous version of the `getHousingLocationById` method. - - + 2. Save your code. 3. Open the application in the browser and confirm that it runs without any errors. diff --git a/adev/src/content/tutorials/first-app/steps/14-http/src-final/app/home/home.ts b/adev/src/content/tutorials/first-app/steps/14-http/src-final/app/home/home.ts index a4a967e27e0..6949c27ea75 100644 --- a/adev/src/content/tutorials/first-app/steps/14-http/src-final/app/home/home.ts +++ b/adev/src/content/tutorials/first-app/steps/14-http/src-final/app/home/home.ts @@ -14,7 +14,7 @@ import {HousingService} from '../housing.service';
- @for(housingLocation of housingLocationList; track $index) { + @for(housingLocation of filteredLocationList; track $index) { }
diff --git a/adev/src/content/tutorials/first-app/steps/14-http/src/app/home/home.ts b/adev/src/content/tutorials/first-app/steps/14-http/src/app/home/home.ts index fa9fe91d856..7f8e1ed01b1 100644 --- a/adev/src/content/tutorials/first-app/steps/14-http/src/app/home/home.ts +++ b/adev/src/content/tutorials/first-app/steps/14-http/src/app/home/home.ts @@ -14,7 +14,7 @@ import {HousingService} from '../housing.service';
- @for(housingLocation of housingLocationList; track $index) { + @for(housingLocation of filteredLocationList; track $index) { }
diff --git a/adev/src/content/tutorials/learn-angular/steps/11-optimizing-images/README.md b/adev/src/content/tutorials/learn-angular/steps/11-optimizing-images/README.md index 6c085fe927c..f40d54d5e2e 100644 --- a/adev/src/content/tutorials/learn-angular/steps/11-optimizing-images/README.md +++ b/adev/src/content/tutorials/learn-angular/steps/11-optimizing-images/README.md @@ -35,7 +35,8 @@ To enable the `NgOptimizedImage` directive, swap out the `src` attribute for `ng import { NgOptimizedImage } from '@angular/common'; @Component({ -template: ` ... + template: ` + ...
  • Static Image: Angular logo @@ -46,7 +47,7 @@ template: ` ...
  • ... `, -imports: [NgOptimizedImage], + imports: [NgOptimizedImage], })
    diff --git a/adev/src/content/tutorials/learn-angular/steps/12-enable-routing/README.md b/adev/src/content/tutorials/learn-angular/steps/12-enable-routing/README.md index 3009baa3143..fd0fbfef48c 100644 --- a/adev/src/content/tutorials/learn-angular/steps/12-enable-routing/README.md +++ b/adev/src/content/tutorials/learn-angular/steps/12-enable-routing/README.md @@ -39,7 +39,7 @@ import {provideRouter} from '@angular/router'; import {routes} from './app.routes'; export const appConfig: ApplicationConfig = { -providers: [provideRouter(routes)], + providers: [provideRouter(routes)], };
    @@ -55,15 +55,16 @@ Update the template for `App` by adding `` import {RouterOutlet} from '@angular/router'; @Component({ -... -template: `