_id
stringlengths 21
254
| text
stringlengths 1
93.7k
| metadata
dict |
---|---|---|
angular/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/main.ts_0_420 | /*
* Protractor support is deprecated in Angular.
* Protractor is used in this example for compatibility with Angular documentation tools.
*/
import {bootstrapApplication, provideProtractorTestingSupport} from '@angular/platform-browser';
import {AppComponent} from './app/app.component';
bootstrapApplication(AppComponent, {providers: [provideProtractorTestingSupport()]}).catch((err) =>
console.error(err),
);
| {
"end_byte": 420,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/main.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/styles.css_0_443 | /* You can add global styles to this file, and also import other style files */
* {
margin: 0;
padding: 0;
}
body {
font-family: 'Be Vietnam Pro', sans-serif;
}
:root {
--primary-color: #605DC8;
--secondary-color: #8B89E6;
--accent-color: #e8e7fa;
--shadow-color: #E8E8E8;
}
button.primary {
padding: 10px;
border: solid 1px var(--primary-color);
background: var(--primary-color);
color: white;
border-radius: 8px;
}
| {
"end_byte": 443,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/styles.css"
} |
angular/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/app/app.component.ts_0_249 | import {Component} from '@angular/core';
@Component({
selector: 'app-root',
standalone: true,
imports: [],
template: `
<h1>Hello world!</h1>
`,
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'homes';
}
| {
"end_byte": 249,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/app/app.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/app/app.component.css_0_213 | :host {
--content-padding: 10px;
}
header {
display: block;
height: 60px;
padding: var(--content-padding);
box-shadow: 0px 5px 25px var(--shadow-color);
}
.content {
padding: var(--content-padding);
}
| {
"end_byte": 213,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/app/app.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/assets/location-pin.svg_0_502 | <?xml version="1.0" encoding="UTF-8"?>
<svg width="20pt" height="20pt" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<path d="m50 11.602c-15.398 0-27.898 12.5-27.898 27.898 0 5 1.3008 9.6992 3.6016 13.801l2.8984 4.1992 21.398 30.898 21.801-31.398 2.1992-3.1992c2.5-4.1992 3.8984-9 3.8984-14.199 0-15.5-12.5-28-27.898-28zm0 35.598c-4.1992 0-7.6992-3.3984-7.6992-7.6992s3.3984-7.6992 7.6992-7.6992 7.6992 3.3984 7.6992 7.6992-3.5 7.6992-7.6992 7.6992z" fill="#605cc8"/>
</svg>
| {
"end_byte": 502,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/assets/location-pin.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/assets/logo.svg_0_2207 | <svg width="151" height="44" viewBox="0 0 151 44" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.15532 33.2946C5.25369 33.2946 4.58006 32.5707 4.58006 31.6701V24.0152C4.58006 19.5469 4.35206 20.6276 7.59585 17.4236C21.7317 4.06732 16.2425 4.24744 29.6149 18.054C32.0434 20.7627 31.9985 19.4534 31.9985 23.8316V31.6667C31.9985 32.5707 31.28 33.2912 30.3749 33.2912H6.15532V33.2946Z" fill="#605DC8"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M30.896 35.1547L5.73676 35.2586C4.80059 35.2621 3.75042 35.8232 3.37388 36.5229L2.90061 37.4027L0.537726 41.7878L0.140457 42.529C-0.236085 43.2253 0.164639 43.7829 1.10081 43.7795L26.26 43.6756C27.1962 43.6721 28.2464 43.111 28.6229 42.4113L29.0962 41.5315L31.4591 37.1463L31.8563 36.4051C32.2329 35.7089 31.8321 35.1512 30.896 35.1547Z" fill="#605DC8"/>
<path d="M2.54861 18.7156C2.23079 18.7156 1.90952 18.629 1.6228 18.4454C0.821352 17.9363 0.5899 16.859 1.09771 16.0554C1.46389 15.4701 2.70061 14.2231 5.50912 11.4659L6.39693 10.5931C8.73218 8.38318 10.5147 6.56817 11.9449 5.10646C15.1679 1.81587 16.7985 0.153263 18.9023 0.222538C20.9888 0.277958 22.4362 1.92325 25.3138 5.19651C26.7267 6.8037 28.4816 8.8023 30.8514 11.2477C30.8652 11.265 30.8825 11.2789 30.8963 11.2962C31.228 11.6634 31.715 12.2003 32.2401 12.7752C33.9743 14.6734 34.8206 15.6086 35.0763 15.9688C35.629 16.7413 35.4494 17.8185 34.679 18.3727C33.9087 18.9234 32.8343 18.7468 32.2816 17.9744C32.0639 17.6869 30.5889 16.0693 29.708 15.1064C29.1863 14.5348 28.6993 14.0014 28.3642 13.6308C25.9495 11.1369 24.1704 9.11057 22.7368 7.4826C21.0233 5.5325 19.4032 3.68977 18.809 3.67245H18.8021C18.1699 3.67245 16.3356 5.54289 14.3976 7.52417C12.9467 9.00666 11.14 10.8494 8.78054 13.0766L7.91001 13.9321C6.74929 15.0717 4.33804 17.4375 3.97877 17.9293C3.65405 18.4454 3.10824 18.7225 2.54515 18.7225L2.54861 18.7156Z" fill="#605DC8"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.0976 33.2115V26.0588C22.0976 25.4665 21.6174 24.985 21.0267 24.985H15.1955C14.6047 24.985 14.1246 25.4665 14.1246 26.0588V33.2115C14.1246 33.2704 14.1142 33.3293 14.0969 33.3847H22.1252C22.1079 33.3293 22.0976 33.2739 22.0976 33.2115Z" fill="white"/> | {
"end_byte": 2207,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/assets/logo.svg_2208_5628 | <path d="M58.9784 10.0512V32.2205H54.5319V22.7874H45.0353V32.2205H40.5887V10.0512H45.0353V19.1666H54.5319V10.0512H58.9784ZM70.8506 32.5063C69.1567 32.5063 67.6322 32.1358 66.277 31.3947C64.9219 30.6324 63.8526 29.5631 63.0692 28.1868C62.3069 26.8105 61.9258 25.2224 61.9258 23.4226C61.9258 21.6228 62.3175 20.0348 63.1009 18.6585C63.9055 17.2821 64.996 16.2234 66.3723 15.4823C67.7486 14.7201 69.2838 14.3389 70.9777 14.3389C72.6716 14.3389 74.2067 14.7201 75.5831 15.4823C76.9594 16.2234 78.0393 17.2821 78.8227 18.6585C79.6273 20.0348 80.0296 21.6228 80.0296 23.4226C80.0296 25.2224 79.6167 26.8105 78.7909 28.1868C77.9863 29.5631 76.8853 30.6324 75.4878 31.3947C74.1115 32.1358 72.5657 32.5063 70.8506 32.5063ZM70.8506 28.6315C71.6553 28.6315 72.4069 28.4409 73.1057 28.0597C73.8256 27.6574 74.3973 27.0646 74.8208 26.2811C75.2443 25.4977 75.456 24.5449 75.456 23.4226C75.456 21.7499 75.0114 20.4688 74.122 19.5795C73.2539 18.669 72.1846 18.2138 70.9142 18.2138C69.6437 18.2138 68.5744 18.669 67.7063 19.5795C66.8593 20.4688 66.4358 21.7499 66.4358 23.4226C66.4358 25.0954 66.8487 26.387 67.6745 27.2975C68.5215 28.1868 69.5802 28.6315 70.8506 28.6315ZM104.825 14.3707C106.985 14.3707 108.721 15.0377 110.034 16.3717C111.368 17.6844 112.035 19.5266 112.035 21.8981V32.2205H107.589V22.5016C107.589 21.1252 107.239 20.0771 106.54 19.3572C105.842 18.6161 104.889 18.2456 103.682 18.2456C102.475 18.2456 101.512 18.6161 100.792 19.3572C100.093 20.0771 99.7436 21.1252 99.7436 22.5016V32.2205H95.297V22.5016C95.297 21.1252 94.9477 20.0771 94.2489 19.3572C93.5502 18.6161 92.5974 18.2456 91.3904 18.2456C90.1623 18.2456 89.1883 18.6161 88.4684 19.3572C87.7697 20.0771 87.4203 21.1252 87.4203 22.5016V32.2205H82.9737V14.6248H87.4203V16.7528C87.992 16.0117 88.7225 15.4294 89.6118 15.0059C90.5223 14.5824 91.5175 14.3707 92.5974 14.3707C93.9737 14.3707 95.2018 14.6671 96.2816 15.26C97.3615 15.8317 98.1979 16.6575 98.7908 17.7374C99.3625 16.721 100.188 15.9058 101.268 15.2918C102.369 14.6777 103.555 14.3707 104.825 14.3707ZM132.294 23.0415C132.294 23.6767 132.252 24.2484 132.167 24.7566H119.304C119.41 26.027 119.854 27.0222 120.638 27.7421C121.421 28.4621 122.385 28.822 123.528 28.822C125.18 28.822 126.355 28.1127 127.053 26.694H131.849C131.341 28.3879 130.367 29.7854 128.927 30.8865C127.488 31.9664 125.72 32.5063 123.623 32.5063C121.929 32.5063 120.405 32.1358 119.05 31.3947C117.716 30.6324 116.668 29.5631 115.905 28.1868C115.164 26.8105 114.794 25.2224 114.794 23.4226C114.794 21.6017 115.164 20.003 115.905 18.6267C116.646 17.2504 117.684 16.1917 119.018 15.4506C120.352 14.7095 121.887 14.3389 123.623 14.3389C125.296 14.3389 126.789 14.6989 128.102 15.4188C129.436 16.1387 130.462 17.1657 131.182 18.4996C131.924 19.8124 132.294 21.3264 132.294 23.0415ZM127.689 21.771C127.668 20.6276 127.255 19.7172 126.45 19.0396C125.645 18.3408 124.661 17.9915 123.496 17.9915C122.395 17.9915 121.464 18.3303 120.701 19.0078C119.96 19.6642 119.505 20.5853 119.336 21.771H127.689ZM141.955 32.5063C140.516 32.5063 139.224 32.2522 138.081 31.744C136.937 31.2147 136.027 30.5054 135.349 29.616C134.693 28.7267 134.333 27.7421 134.269 26.6623H138.748C138.832 27.3398 139.16 27.9009 139.732 28.3456C140.325 28.7903 141.055 29.0126 141.924 29.0126C142.771 29.0126 143.427 28.8432 143.893 28.5044C144.38 28.1656 144.623 27.7316 144.623 27.2022C144.623 26.6305 144.327 26.207 143.734 25.9318C143.162 25.6353 142.241 25.3177 140.971 | {
"end_byte": 5628,
"start_byte": 2208,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/assets/logo.svg_5629_6611 | 24.9789C139.658 24.6613 138.578 24.3331 137.731 23.9943C136.905 23.6555 136.185 23.1368 135.571 22.438C134.979 21.7393 134.682 20.797 134.682 19.6113C134.682 18.6373 134.957 17.748 135.508 16.9434C136.08 16.1387 136.884 15.5035 137.922 15.0377C138.98 14.5719 140.219 14.3389 141.638 14.3389C143.734 14.3389 145.407 14.8683 146.656 15.927C147.905 16.9645 148.593 18.3726 148.721 20.1512H144.465C144.401 19.4525 144.105 18.902 143.575 18.4996C143.067 18.0762 142.379 17.8644 141.511 17.8644C140.706 17.8644 140.081 18.0126 139.637 18.3091C139.213 18.6055 139.002 19.0184 139.002 19.5478C139.002 20.1406 139.298 20.5959 139.891 20.9135C140.484 21.2099 141.405 21.517 142.654 21.8346C143.925 22.1522 144.973 22.4804 145.798 22.8192C146.624 23.1579 147.334 23.6873 147.926 24.4072C148.541 25.106 148.858 26.0376 148.879 27.2022C148.879 28.2186 148.593 29.129 148.022 29.9337C147.471 30.7383 146.667 31.3735 145.608 31.8393C144.57 32.284 143.353 32.5063 141.955 32.5063Z" fill="#605DC8"/> | {
"end_byte": 6611,
"start_byte": 5629,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/assets/logo.svg_6612_6619 | </svg>
| {
"end_byte": 6619,
"start_byte": 6612,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/02-HomeComponent/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/README.md_0_5924 | # Angular services
This tutorial lesson demonstrates how to create an Angular service and use dependency injection to include it in your app.
<docs-video src="https://www.youtube.com/embed/-jRxG84AzCI?si=rieGfJawp9xJ00Sz"/>
## What you'll learn
Your app has a service to serve the data to your app.
At the end of this lesson, the service reads data from local, static data.
In a later lesson, you'll update the service to get data from a web service.
## Conceptual preview of services
This tutorial introduces Angular services and dependency injection.
### Angular services
*Angular services* provide a way for you to separate Angular app data and functions that can be used by multiple components in your app.
To be used by multiple components, a service must be made *injectable*.
Services that are injectable and used by a component become dependencies of that component.
The component depends on those services and can't function without them.
### Dependency injection
*Dependency injection* is the mechanism that manages the dependencies of an app's components and the services that other components can use.
<docs-workflow>
<docs-step title="Create a new service for your app">
This step creates an injectable service for your app.
In the **Terminal** pane of your IDE:
1. In your project directory, navigate to the `first-app` directory.
1. In the `first-app` directory, run this command to create the new service.
<docs-code language="shell">
ng generate service housing --skip-tests
</docs-code>
1. Run `ng serve` to build the app and serve it to `http://localhost:4200`.
1. Confirm that the app builds without error.
Correct any errors before you continue to the next step.
</docs-step>
<docs-step title="Add static data to the new service">
This step adds some sample data to your new service.
In a later lesson, you'll replace the static data with a web interface to get data as you might in a real app.
For now, your app's new service uses the data that has, so far, been created locally in `HomeComponent`.
In the **Edit** pane of your IDE:
1. In `src/app/home/home.component.ts`, from `HomeComponent`, copy the `housingLocationList` variable and its array value.
1. In `src/app/housing.service.ts`:
1. Inside the `HousingService` class, paste the variable that you copied from `HomeComponent` in the previous step.
1. Inside the `HousingService` class, paste these functions after the data you just copied.
These functions allow dependencies to access the service's data.
<docs-code header="Service functions in src/app/housing.service.ts" path="adev/src/content/tutorials/first-app/steps/10-routing/src/app/housing.service.ts" visibleLines="[112,118]"/>
You will need these functions in a future lesson. For now, it is enough to understand that these functions return either a specific `HousingLocation` by id or the entire list.
1. Add a file level import for the `HousingLocation`.
<docs-code header="Import HousingLocation type in src/app/housing.service.ts" path="adev/src/content/tutorials/first-app/steps/10-routing/src/app/housing.service.ts" visibleLines="[2]"/>
1. Confirm that the app builds without error.
Correct any errors before you continue to the next step.
</docs-step>
<docs-step title="Inject the new service into `HomeComponent`">
This step injects the new service into your app's `HomeComponent` so that it can read the app's data from a service.
In a later lesson, you'll replace the static data with a live data source to get data as you might in a real app.
In the **Edit** pane of your IDE, in `src/app/home/home.component.ts`:
1. At the top of `src/app/home/home.component.ts`, add the `inject` to the items imported from `@angular/core`. This will import the `inject` function into the `HomeComponent` class.
<docs-code header="Update to src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/10-routing/src/app/home/home.component.ts" visibleLines="[1]"/>
1. Add a new file level import for the `HousingService`:
<docs-code header="Add import to src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/10-routing/src/app/home/home.component.ts" visibleLines="[5]"/>
1. From `HomeComponent`, delete the `housingLocationList` array entries and assign `housingLocationList` the value of empty array (`[]`). In a few steps you will update the code to pull the data from the `HousingService`.
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`.
<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]"/>
1. Save the changes to `src/app/home/home.component.ts` and confirm your app builds without error.
Correct any errors before you continue to the next step.
</docs-step>
</docs-workflow>
Summary: In this lesson, you added an Angular service to your app and injected it into the `HomeComponent` class.
This compartmentalizes how your app gets its data.
For now, the new service gets its data from a static array of data.
In a later lesson, you'll refactor the service to get its data from an API endpoint.
For more information about the topics covered in this lesson, visit:
<docs-pill-row>
<docs-pill href="guide/di/creating-injectable-service" title="Creating an injectable service"/>
<docs-pill href="guide/di" title="Dependency injection in Angular"/>
<docs-pill href="cli/generate/service" title="ng generate service"/>
<docs-pill href="cli/generate" title="ng generate"/>
</docs-pill-row>
| {
"end_byte": 5924,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/README.md"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/index.html_0_427 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Homes</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
</head>
<body>
<app-root></app-root>
</body>
</html>
| {
"end_byte": 427,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/index.html"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/main.ts_0_420 | /*
* Protractor support is deprecated in Angular.
* Protractor is used in this example for compatibility with Angular documentation tools.
*/
import {bootstrapApplication, provideProtractorTestingSupport} from '@angular/platform-browser';
import {AppComponent} from './app/app.component';
bootstrapApplication(AppComponent, {providers: [provideProtractorTestingSupport()]}).catch((err) =>
console.error(err),
);
| {
"end_byte": 420,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/main.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/styles.css_0_443 | /* You can add global styles to this file, and also import other style files */
* {
margin: 0;
padding: 0;
}
body {
font-family: 'Be Vietnam Pro', sans-serif;
}
:root {
--primary-color: #605DC8;
--secondary-color: #8B89E6;
--accent-color: #e8e7fa;
--shadow-color: #E8E8E8;
}
button.primary {
padding: 10px;
border: solid 1px var(--primary-color);
background: var(--primary-color);
color: white;
border-radius: 8px;
}
| {
"end_byte": 443,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/styles.css"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/app/housinglocation.ts_0_180 | export interface HousingLocation {
id: number;
name: string;
city: string;
state: string;
photo: string;
availableUnits: number;
wifi: boolean;
laundry: boolean;
}
| {
"end_byte": 180,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/app/housinglocation.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/app/app.component.ts_0_529 | import {Component} from '@angular/core';
import {HomeComponent} from './home/home.component';
@Component({
selector: 'app-root',
standalone: true,
imports: [HomeComponent],
template: `
<main>
<header class="brand-name">
<img class="brand-logo" src="/assets/logo.svg" alt="logo" aria-hidden="true" />
</header>
<section class="content">
<app-home></app-home>
</section>
</main>
`,
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'homes';
}
| {
"end_byte": 529,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/app/app.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/app/app.component.css_0_213 | :host {
--content-padding: 10px;
}
header {
display: block;
height: 60px;
padding: var(--content-padding);
box-shadow: 0px 5px 25px var(--shadow-color);
}
.content {
padding: var(--content-padding);
}
| {
"end_byte": 213,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/app/app.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/app/home/home.component.ts_0_3366 | import {Component} from '@angular/core';
import {CommonModule} from '@angular/common';
import {HousingLocationComponent} from '../housing-location/housing-location.component';
import {HousingLocation} from '../housinglocation';
@Component({
selector: 'app-home',
standalone: true,
imports: [CommonModule, HousingLocationComponent],
template: `
<section>
<form>
<input type="text" placeholder="Filter by city" />
<button class="primary" type="button">Search</button>
</form>
</section>
<section class="results">
<app-housing-location
*ngFor="let housingLocation of housingLocationList"
[housingLocation]="housingLocation"
></app-housing-location>
</section>
`,
styleUrls: ['./home.component.css'],
})
export class HomeComponent {
readonly baseUrl = 'https://angular.dev/assets/images/tutorials/common';
housingLocationList: HousingLocation[] = [
{
id: 0,
name: 'Acme Fresh Start Housing',
city: 'Chicago',
state: 'IL',
photo: `${this.baseUrl}/bernard-hermant-CLKGGwIBTaY-unsplash.jpg`,
availableUnits: 4,
wifi: true,
laundry: true,
},
{
id: 1,
name: 'A113 Transitional Housing',
city: 'Santa Monica',
state: 'CA',
photo: `${this.baseUrl}/brandon-griggs-wR11KBaB86U-unsplash.jpg`,
availableUnits: 0,
wifi: false,
laundry: true,
},
{
id: 2,
name: 'Warm Beds Housing Support',
city: 'Juneau',
state: 'AK',
photo: `${this.baseUrl}/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: `${this.baseUrl}/ian-macdonald-W8z6aiwfi1E-unsplash.jpg`,
availableUnits: 1,
wifi: true,
laundry: false,
},
{
id: 4,
name: 'Happy Homes Group',
city: 'Gary',
state: 'IN',
photo: `${this.baseUrl}/krzysztof-hepner-978RAXoXnH4-unsplash.jpg`,
availableUnits: 1,
wifi: true,
laundry: false,
},
{
id: 5,
name: 'Hopeful Apartment Group',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/r-architecture-JvQ0Q5IkeMM-unsplash.jpg`,
availableUnits: 2,
wifi: true,
laundry: true,
},
{
id: 6,
name: 'Seriously Safe Towns',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/phil-hearing-IYfp2Ixe9nM-unsplash.jpg`,
availableUnits: 5,
wifi: true,
laundry: true,
},
{
id: 7,
name: 'Hopeful Housing Solutions',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/r-architecture-GGupkreKwxA-unsplash.jpg`,
availableUnits: 2,
wifi: true,
laundry: true,
},
{
id: 8,
name: 'Seriously Safe Towns',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/saru-robert-9rP3mxf8qWI-unsplash.jpg`,
availableUnits: 10,
wifi: false,
laundry: false,
},
{
id: 9,
name: 'Capital Safe Towns',
city: 'Portland',
state: 'OR',
photo: `${this.baseUrl}/webaliser-_TPTXZd9mOo-unsplash.jpg`,
availableUnits: 6,
wifi: true,
laundry: true,
},
];
}
| {
"end_byte": 3366,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/app/home/home.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/app/home/home.component.css_0_746 | .results {
display: grid;
column-gap: 14px;
row-gap: 14px;
grid-template-columns: repeat(auto-fill, minmax(400px, 400px));
margin-top: 50px;
justify-content: space-around;
}
input[type="text"] {
border: solid 1px var(--primary-color);
padding: 10px;
border-radius: 8px;
margin-right: 4px;
display: inline-block;
width: 30%;
}
button {
padding: 10px;
border: solid 1px var(--primary-color);
background: var(--primary-color);
color: white;
border-radius: 8px;
}
@media (min-width: 500px) and (max-width: 768px) {
.results {
grid-template-columns: repeat(2, 1fr);
}
input[type="text"] {
width: 70%;
}
}
@media (max-width: 499px) {
.results {
grid-template-columns: 1fr;
}
}
| {
"end_byte": 746,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/app/home/home.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/app/housing-location/housing-location.component.css_0_583 | .listing {
background: var(--accent-color);
border-radius: 30px;
padding-bottom: 30px;
}
.listing-heading {
color: var(--primary-color);
padding: 10px 20px 0 20px;
}
.listing-photo {
height: 250px;
width: 100%;
object-fit: cover;
border-radius: 30px 30px 0 0;
}
.listing-location {
padding: 10px 20px 20px 20px;
}
.listing-location::before {
content: url("/assets/location-pin.svg") / "";
}
section.listing a {
padding-left: 20px;
text-decoration: none;
color: var(--primary-color);
}
section.listing a::after {
content: "\203A";
margin-left: 5px;
}
| {
"end_byte": 583,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/app/housing-location/housing-location.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/app/housing-location/housing-location.component.ts_0_776 | import {Component, Input} from '@angular/core';
import {CommonModule} from '@angular/common';
import {HousingLocation} from '../housinglocation';
@Component({
selector: 'app-housing-location',
standalone: true,
imports: [CommonModule],
template: `
<section class="listing">
<img
class="listing-photo"
[src]="housingLocation.photo"
alt="Exterior photo of {{ housingLocation.name }}"
crossorigin
/>
<h2 class="listing-heading">{{ housingLocation.name }}</h2>
<p class="listing-location">{{ housingLocation.city }}, {{ housingLocation.state }}</p>
</section>
`,
styleUrls: ['./housing-location.component.css'],
})
export class HousingLocationComponent {
@Input() housingLocation!: HousingLocation;
}
| {
"end_byte": 776,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/app/housing-location/housing-location.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/assets/location-pin.svg_0_502 | <?xml version="1.0" encoding="UTF-8"?>
<svg width="20pt" height="20pt" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<path d="m50 11.602c-15.398 0-27.898 12.5-27.898 27.898 0 5 1.3008 9.6992 3.6016 13.801l2.8984 4.1992 21.398 30.898 21.801-31.398 2.1992-3.1992c2.5-4.1992 3.8984-9 3.8984-14.199 0-15.5-12.5-28-27.898-28zm0 35.598c-4.1992 0-7.6992-3.3984-7.6992-7.6992s3.3984-7.6992 7.6992-7.6992 7.6992 3.3984 7.6992 7.6992-3.5 7.6992-7.6992 7.6992z" fill="#605cc8"/>
</svg>
| {
"end_byte": 502,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/assets/location-pin.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/assets/logo.svg_0_2207 | <svg width="151" height="44" viewBox="0 0 151 44" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.15532 33.2946C5.25369 33.2946 4.58006 32.5707 4.58006 31.6701V24.0152C4.58006 19.5469 4.35206 20.6276 7.59585 17.4236C21.7317 4.06732 16.2425 4.24744 29.6149 18.054C32.0434 20.7627 31.9985 19.4534 31.9985 23.8316V31.6667C31.9985 32.5707 31.28 33.2912 30.3749 33.2912H6.15532V33.2946Z" fill="#605DC8"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M30.896 35.1547L5.73676 35.2586C4.80059 35.2621 3.75042 35.8232 3.37388 36.5229L2.90061 37.4027L0.537726 41.7878L0.140457 42.529C-0.236085 43.2253 0.164639 43.7829 1.10081 43.7795L26.26 43.6756C27.1962 43.6721 28.2464 43.111 28.6229 42.4113L29.0962 41.5315L31.4591 37.1463L31.8563 36.4051C32.2329 35.7089 31.8321 35.1512 30.896 35.1547Z" fill="#605DC8"/>
<path d="M2.54861 18.7156C2.23079 18.7156 1.90952 18.629 1.6228 18.4454C0.821352 17.9363 0.5899 16.859 1.09771 16.0554C1.46389 15.4701 2.70061 14.2231 5.50912 11.4659L6.39693 10.5931C8.73218 8.38318 10.5147 6.56817 11.9449 5.10646C15.1679 1.81587 16.7985 0.153263 18.9023 0.222538C20.9888 0.277958 22.4362 1.92325 25.3138 5.19651C26.7267 6.8037 28.4816 8.8023 30.8514 11.2477C30.8652 11.265 30.8825 11.2789 30.8963 11.2962C31.228 11.6634 31.715 12.2003 32.2401 12.7752C33.9743 14.6734 34.8206 15.6086 35.0763 15.9688C35.629 16.7413 35.4494 17.8185 34.679 18.3727C33.9087 18.9234 32.8343 18.7468 32.2816 17.9744C32.0639 17.6869 30.5889 16.0693 29.708 15.1064C29.1863 14.5348 28.6993 14.0014 28.3642 13.6308C25.9495 11.1369 24.1704 9.11057 22.7368 7.4826C21.0233 5.5325 19.4032 3.68977 18.809 3.67245H18.8021C18.1699 3.67245 16.3356 5.54289 14.3976 7.52417C12.9467 9.00666 11.14 10.8494 8.78054 13.0766L7.91001 13.9321C6.74929 15.0717 4.33804 17.4375 3.97877 17.9293C3.65405 18.4454 3.10824 18.7225 2.54515 18.7225L2.54861 18.7156Z" fill="#605DC8"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.0976 33.2115V26.0588C22.0976 25.4665 21.6174 24.985 21.0267 24.985H15.1955C14.6047 24.985 14.1246 25.4665 14.1246 26.0588V33.2115C14.1246 33.2704 14.1142 33.3293 14.0969 33.3847H22.1252C22.1079 33.3293 22.0976 33.2739 22.0976 33.2115Z" fill="white"/> | {
"end_byte": 2207,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/assets/logo.svg_2208_5628 | <path d="M58.9784 10.0512V32.2205H54.5319V22.7874H45.0353V32.2205H40.5887V10.0512H45.0353V19.1666H54.5319V10.0512H58.9784ZM70.8506 32.5063C69.1567 32.5063 67.6322 32.1358 66.277 31.3947C64.9219 30.6324 63.8526 29.5631 63.0692 28.1868C62.3069 26.8105 61.9258 25.2224 61.9258 23.4226C61.9258 21.6228 62.3175 20.0348 63.1009 18.6585C63.9055 17.2821 64.996 16.2234 66.3723 15.4823C67.7486 14.7201 69.2838 14.3389 70.9777 14.3389C72.6716 14.3389 74.2067 14.7201 75.5831 15.4823C76.9594 16.2234 78.0393 17.2821 78.8227 18.6585C79.6273 20.0348 80.0296 21.6228 80.0296 23.4226C80.0296 25.2224 79.6167 26.8105 78.7909 28.1868C77.9863 29.5631 76.8853 30.6324 75.4878 31.3947C74.1115 32.1358 72.5657 32.5063 70.8506 32.5063ZM70.8506 28.6315C71.6553 28.6315 72.4069 28.4409 73.1057 28.0597C73.8256 27.6574 74.3973 27.0646 74.8208 26.2811C75.2443 25.4977 75.456 24.5449 75.456 23.4226C75.456 21.7499 75.0114 20.4688 74.122 19.5795C73.2539 18.669 72.1846 18.2138 70.9142 18.2138C69.6437 18.2138 68.5744 18.669 67.7063 19.5795C66.8593 20.4688 66.4358 21.7499 66.4358 23.4226C66.4358 25.0954 66.8487 26.387 67.6745 27.2975C68.5215 28.1868 69.5802 28.6315 70.8506 28.6315ZM104.825 14.3707C106.985 14.3707 108.721 15.0377 110.034 16.3717C111.368 17.6844 112.035 19.5266 112.035 21.8981V32.2205H107.589V22.5016C107.589 21.1252 107.239 20.0771 106.54 19.3572C105.842 18.6161 104.889 18.2456 103.682 18.2456C102.475 18.2456 101.512 18.6161 100.792 19.3572C100.093 20.0771 99.7436 21.1252 99.7436 22.5016V32.2205H95.297V22.5016C95.297 21.1252 94.9477 20.0771 94.2489 19.3572C93.5502 18.6161 92.5974 18.2456 91.3904 18.2456C90.1623 18.2456 89.1883 18.6161 88.4684 19.3572C87.7697 20.0771 87.4203 21.1252 87.4203 22.5016V32.2205H82.9737V14.6248H87.4203V16.7528C87.992 16.0117 88.7225 15.4294 89.6118 15.0059C90.5223 14.5824 91.5175 14.3707 92.5974 14.3707C93.9737 14.3707 95.2018 14.6671 96.2816 15.26C97.3615 15.8317 98.1979 16.6575 98.7908 17.7374C99.3625 16.721 100.188 15.9058 101.268 15.2918C102.369 14.6777 103.555 14.3707 104.825 14.3707ZM132.294 23.0415C132.294 23.6767 132.252 24.2484 132.167 24.7566H119.304C119.41 26.027 119.854 27.0222 120.638 27.7421C121.421 28.4621 122.385 28.822 123.528 28.822C125.18 28.822 126.355 28.1127 127.053 26.694H131.849C131.341 28.3879 130.367 29.7854 128.927 30.8865C127.488 31.9664 125.72 32.5063 123.623 32.5063C121.929 32.5063 120.405 32.1358 119.05 31.3947C117.716 30.6324 116.668 29.5631 115.905 28.1868C115.164 26.8105 114.794 25.2224 114.794 23.4226C114.794 21.6017 115.164 20.003 115.905 18.6267C116.646 17.2504 117.684 16.1917 119.018 15.4506C120.352 14.7095 121.887 14.3389 123.623 14.3389C125.296 14.3389 126.789 14.6989 128.102 15.4188C129.436 16.1387 130.462 17.1657 131.182 18.4996C131.924 19.8124 132.294 21.3264 132.294 23.0415ZM127.689 21.771C127.668 20.6276 127.255 19.7172 126.45 19.0396C125.645 18.3408 124.661 17.9915 123.496 17.9915C122.395 17.9915 121.464 18.3303 120.701 19.0078C119.96 19.6642 119.505 20.5853 119.336 21.771H127.689ZM141.955 32.5063C140.516 32.5063 139.224 32.2522 138.081 31.744C136.937 31.2147 136.027 30.5054 135.349 29.616C134.693 28.7267 134.333 27.7421 134.269 26.6623H138.748C138.832 27.3398 139.16 27.9009 139.732 28.3456C140.325 28.7903 141.055 29.0126 141.924 29.0126C142.771 29.0126 143.427 28.8432 143.893 28.5044C144.38 28.1656 144.623 27.7316 144.623 27.2022C144.623 26.6305 144.327 26.207 143.734 25.9318C143.162 25.6353 142.241 25.3177 140.971 | {
"end_byte": 5628,
"start_byte": 2208,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/assets/logo.svg_5629_6611 | 24.9789C139.658 24.6613 138.578 24.3331 137.731 23.9943C136.905 23.6555 136.185 23.1368 135.571 22.438C134.979 21.7393 134.682 20.797 134.682 19.6113C134.682 18.6373 134.957 17.748 135.508 16.9434C136.08 16.1387 136.884 15.5035 137.922 15.0377C138.98 14.5719 140.219 14.3389 141.638 14.3389C143.734 14.3389 145.407 14.8683 146.656 15.927C147.905 16.9645 148.593 18.3726 148.721 20.1512H144.465C144.401 19.4525 144.105 18.902 143.575 18.4996C143.067 18.0762 142.379 17.8644 141.511 17.8644C140.706 17.8644 140.081 18.0126 139.637 18.3091C139.213 18.6055 139.002 19.0184 139.002 19.5478C139.002 20.1406 139.298 20.5959 139.891 20.9135C140.484 21.2099 141.405 21.517 142.654 21.8346C143.925 22.1522 144.973 22.4804 145.798 22.8192C146.624 23.1579 147.334 23.6873 147.926 24.4072C148.541 25.106 148.858 26.0376 148.879 27.2022C148.879 28.2186 148.593 29.129 148.022 29.9337C147.471 30.7383 146.667 31.3735 145.608 31.8393C144.57 32.284 143.353 32.5063 141.955 32.5063Z" fill="#605DC8"/> | {
"end_byte": 6611,
"start_byte": 5629,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/09-services/src/assets/logo.svg_6612_6619 | </svg>
| {
"end_byte": 6619,
"start_byte": 6612,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/09-services/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/03-HousingLocation/README.md_0_4001 | # Create the application’s HousingLocation component
This tutorial lesson demonstrates how to add the `HousingLocation` component to your Angular app.
<docs-video src="https://www.youtube.com/embed/R0nRX8jD2D0?si=U4ONEbPvtptdUHTt&start=440"/>
## What you'll learn
* Your app has a new component: `HousingLocationComponent` and it displays a message confirming that the component was added to your application.
<docs-workflow>
<docs-step title="Create the `HousingLocationComponent`">
In this step, you create a new component for your app.
In the **Terminal** pane of your IDE:
1. In your project directory, navigate to the `first-app` directory.
1. Run this command to create a new `HousingLocationComponent`
<docs-code language="shell">
ng generate component housingLocation
</docs-code>
1. Run this command to build and serve your app.
<docs-code language="shell">
ng serve
</docs-code>
Note: This step is only for your local environment!
1. Open a browser and navigate to `http://localhost:4200` to find the application.
1. Confirm that the app builds without error.
HELPFUL: It should render the same as it did in the previous lesson because even though you added a new component, you haven't included it in any of the app's templates, yet.
1. Leave `ng serve` running as you complete the next steps.
</docs-step>
<docs-step title="Add the new component to your app's layout">
In this step, you add the new component, `HousingLocationComponent` to your app's `HomeComponent`, so that it displays in your app's layout.
In the **Edit** pane of your IDE:
1. Open `home.component.ts` in the editor.
1. In `home.component.ts`, import `HousingLocationComponent` by adding this line to the file level imports.
<docs-code header="Import HousingLocationComponent in src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/home/home.component.ts" visibleLines="[3]"/>
1. Next update the `imports` property of the `@Component` metadata by adding `HousingLocationComponent` to the array.
<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]"/>
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.
<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]"/>
</docs-step>
<docs-step title="Add the styles for the component">
In this step, you will copy over the pre-written styles for the `HousingLocationComponent` to your app so that the app renders properly.
1. Open `src/app/housing-location/housing-location.component.css`, and paste the styles below into the file:
Note: In the browser, these can go in `src/app/housing-location/housing-location.component.ts` in the `styles` array.
<docs-code header="Add CSS styles to housing location to the component in src/app/housing-location/housing-location.component.css" path="adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/housing-location/housing-location.component.css"/>
1. Save your code, return to the browser and confirm that the app builds without error. You should find the message "housing-location works!" rendered to the screen.Correct any errors before you continue to the next step.
<img alt="browser frame of homes-app displaying logo, filter text input box and search button and the message 'housing-location works!" src="assets/images/tutorials/first-app/homes-app-lesson-03-step-2.png">
</docs-step>
</docs-workflow>
Summary: In this lesson, you created a new component for your app and added it to the app's layout.
| {
"end_byte": 4001,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/03-HousingLocation/README.md"
} |
angular/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/index.html_0_427 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Homes</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
</head>
<body>
<app-root></app-root>
</body>
</html>
| {
"end_byte": 427,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/index.html"
} |
angular/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/main.ts_0_420 | /*
* Protractor support is deprecated in Angular.
* Protractor is used in this example for compatibility with Angular documentation tools.
*/
import {bootstrapApplication, provideProtractorTestingSupport} from '@angular/platform-browser';
import {AppComponent} from './app/app.component';
bootstrapApplication(AppComponent, {providers: [provideProtractorTestingSupport()]}).catch((err) =>
console.error(err),
);
| {
"end_byte": 420,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/main.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/styles.css_0_443 | /* You can add global styles to this file, and also import other style files */
* {
margin: 0;
padding: 0;
}
body {
font-family: 'Be Vietnam Pro', sans-serif;
}
:root {
--primary-color: #605DC8;
--secondary-color: #8B89E6;
--accent-color: #e8e7fa;
--shadow-color: #E8E8E8;
}
button.primary {
padding: 10px;
border: solid 1px var(--primary-color);
background: var(--primary-color);
color: white;
border-radius: 8px;
}
| {
"end_byte": 443,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/styles.css"
} |
angular/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/app/app.component.ts_0_529 | import {Component} from '@angular/core';
import {HomeComponent} from './home/home.component';
@Component({
selector: 'app-root',
standalone: true,
imports: [HomeComponent],
template: `
<main>
<header class="brand-name">
<img class="brand-logo" src="/assets/logo.svg" alt="logo" aria-hidden="true" />
</header>
<section class="content">
<app-home></app-home>
</section>
</main>
`,
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'homes';
}
| {
"end_byte": 529,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/app/app.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/app/app.component.css_0_213 | :host {
--content-padding: 10px;
}
header {
display: block;
height: 60px;
padding: var(--content-padding);
box-shadow: 0px 5px 25px var(--shadow-color);
}
.content {
padding: var(--content-padding);
}
| {
"end_byte": 213,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/app/app.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/app/home/home.component.ts_0_440 | import {Component} from '@angular/core';
import {CommonModule} from '@angular/common';
@Component({
selector: 'app-home',
standalone: true,
imports: [CommonModule],
template: `
<section>
<form>
<input type="text" placeholder="Filter by city" />
<button class="primary" type="button">Search</button>
</form>
</section>
`,
styleUrls: ['./home.component.css'],
})
export class HomeComponent {}
| {
"end_byte": 440,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/app/home/home.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/app/home/home.component.css_0_746 | .results {
display: grid;
column-gap: 14px;
row-gap: 14px;
grid-template-columns: repeat(auto-fill, minmax(400px, 400px));
margin-top: 50px;
justify-content: space-around;
}
input[type="text"] {
border: solid 1px var(--primary-color);
padding: 10px;
border-radius: 8px;
margin-right: 4px;
display: inline-block;
width: 30%;
}
button {
padding: 10px;
border: solid 1px var(--primary-color);
background: var(--primary-color);
color: white;
border-radius: 8px;
}
@media (min-width: 500px) and (max-width: 768px) {
.results {
grid-template-columns: repeat(2, 1fr);
}
input[type="text"] {
width: 70%;
}
}
@media (max-width: 499px) {
.results {
grid-template-columns: 1fr;
}
}
| {
"end_byte": 746,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/app/home/home.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/assets/location-pin.svg_0_502 | <?xml version="1.0" encoding="UTF-8"?>
<svg width="20pt" height="20pt" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<path d="m50 11.602c-15.398 0-27.898 12.5-27.898 27.898 0 5 1.3008 9.6992 3.6016 13.801l2.8984 4.1992 21.398 30.898 21.801-31.398 2.1992-3.1992c2.5-4.1992 3.8984-9 3.8984-14.199 0-15.5-12.5-28-27.898-28zm0 35.598c-4.1992 0-7.6992-3.3984-7.6992-7.6992s3.3984-7.6992 7.6992-7.6992 7.6992 3.3984 7.6992 7.6992-3.5 7.6992-7.6992 7.6992z" fill="#605cc8"/>
</svg>
| {
"end_byte": 502,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/assets/location-pin.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/assets/logo.svg_0_2207 | <svg width="151" height="44" viewBox="0 0 151 44" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.15532 33.2946C5.25369 33.2946 4.58006 32.5707 4.58006 31.6701V24.0152C4.58006 19.5469 4.35206 20.6276 7.59585 17.4236C21.7317 4.06732 16.2425 4.24744 29.6149 18.054C32.0434 20.7627 31.9985 19.4534 31.9985 23.8316V31.6667C31.9985 32.5707 31.28 33.2912 30.3749 33.2912H6.15532V33.2946Z" fill="#605DC8"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M30.896 35.1547L5.73676 35.2586C4.80059 35.2621 3.75042 35.8232 3.37388 36.5229L2.90061 37.4027L0.537726 41.7878L0.140457 42.529C-0.236085 43.2253 0.164639 43.7829 1.10081 43.7795L26.26 43.6756C27.1962 43.6721 28.2464 43.111 28.6229 42.4113L29.0962 41.5315L31.4591 37.1463L31.8563 36.4051C32.2329 35.7089 31.8321 35.1512 30.896 35.1547Z" fill="#605DC8"/>
<path d="M2.54861 18.7156C2.23079 18.7156 1.90952 18.629 1.6228 18.4454C0.821352 17.9363 0.5899 16.859 1.09771 16.0554C1.46389 15.4701 2.70061 14.2231 5.50912 11.4659L6.39693 10.5931C8.73218 8.38318 10.5147 6.56817 11.9449 5.10646C15.1679 1.81587 16.7985 0.153263 18.9023 0.222538C20.9888 0.277958 22.4362 1.92325 25.3138 5.19651C26.7267 6.8037 28.4816 8.8023 30.8514 11.2477C30.8652 11.265 30.8825 11.2789 30.8963 11.2962C31.228 11.6634 31.715 12.2003 32.2401 12.7752C33.9743 14.6734 34.8206 15.6086 35.0763 15.9688C35.629 16.7413 35.4494 17.8185 34.679 18.3727C33.9087 18.9234 32.8343 18.7468 32.2816 17.9744C32.0639 17.6869 30.5889 16.0693 29.708 15.1064C29.1863 14.5348 28.6993 14.0014 28.3642 13.6308C25.9495 11.1369 24.1704 9.11057 22.7368 7.4826C21.0233 5.5325 19.4032 3.68977 18.809 3.67245H18.8021C18.1699 3.67245 16.3356 5.54289 14.3976 7.52417C12.9467 9.00666 11.14 10.8494 8.78054 13.0766L7.91001 13.9321C6.74929 15.0717 4.33804 17.4375 3.97877 17.9293C3.65405 18.4454 3.10824 18.7225 2.54515 18.7225L2.54861 18.7156Z" fill="#605DC8"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.0976 33.2115V26.0588C22.0976 25.4665 21.6174 24.985 21.0267 24.985H15.1955C14.6047 24.985 14.1246 25.4665 14.1246 26.0588V33.2115C14.1246 33.2704 14.1142 33.3293 14.0969 33.3847H22.1252C22.1079 33.3293 22.0976 33.2739 22.0976 33.2115Z" fill="white"/> | {
"end_byte": 2207,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/assets/logo.svg_2208_5628 | <path d="M58.9784 10.0512V32.2205H54.5319V22.7874H45.0353V32.2205H40.5887V10.0512H45.0353V19.1666H54.5319V10.0512H58.9784ZM70.8506 32.5063C69.1567 32.5063 67.6322 32.1358 66.277 31.3947C64.9219 30.6324 63.8526 29.5631 63.0692 28.1868C62.3069 26.8105 61.9258 25.2224 61.9258 23.4226C61.9258 21.6228 62.3175 20.0348 63.1009 18.6585C63.9055 17.2821 64.996 16.2234 66.3723 15.4823C67.7486 14.7201 69.2838 14.3389 70.9777 14.3389C72.6716 14.3389 74.2067 14.7201 75.5831 15.4823C76.9594 16.2234 78.0393 17.2821 78.8227 18.6585C79.6273 20.0348 80.0296 21.6228 80.0296 23.4226C80.0296 25.2224 79.6167 26.8105 78.7909 28.1868C77.9863 29.5631 76.8853 30.6324 75.4878 31.3947C74.1115 32.1358 72.5657 32.5063 70.8506 32.5063ZM70.8506 28.6315C71.6553 28.6315 72.4069 28.4409 73.1057 28.0597C73.8256 27.6574 74.3973 27.0646 74.8208 26.2811C75.2443 25.4977 75.456 24.5449 75.456 23.4226C75.456 21.7499 75.0114 20.4688 74.122 19.5795C73.2539 18.669 72.1846 18.2138 70.9142 18.2138C69.6437 18.2138 68.5744 18.669 67.7063 19.5795C66.8593 20.4688 66.4358 21.7499 66.4358 23.4226C66.4358 25.0954 66.8487 26.387 67.6745 27.2975C68.5215 28.1868 69.5802 28.6315 70.8506 28.6315ZM104.825 14.3707C106.985 14.3707 108.721 15.0377 110.034 16.3717C111.368 17.6844 112.035 19.5266 112.035 21.8981V32.2205H107.589V22.5016C107.589 21.1252 107.239 20.0771 106.54 19.3572C105.842 18.6161 104.889 18.2456 103.682 18.2456C102.475 18.2456 101.512 18.6161 100.792 19.3572C100.093 20.0771 99.7436 21.1252 99.7436 22.5016V32.2205H95.297V22.5016C95.297 21.1252 94.9477 20.0771 94.2489 19.3572C93.5502 18.6161 92.5974 18.2456 91.3904 18.2456C90.1623 18.2456 89.1883 18.6161 88.4684 19.3572C87.7697 20.0771 87.4203 21.1252 87.4203 22.5016V32.2205H82.9737V14.6248H87.4203V16.7528C87.992 16.0117 88.7225 15.4294 89.6118 15.0059C90.5223 14.5824 91.5175 14.3707 92.5974 14.3707C93.9737 14.3707 95.2018 14.6671 96.2816 15.26C97.3615 15.8317 98.1979 16.6575 98.7908 17.7374C99.3625 16.721 100.188 15.9058 101.268 15.2918C102.369 14.6777 103.555 14.3707 104.825 14.3707ZM132.294 23.0415C132.294 23.6767 132.252 24.2484 132.167 24.7566H119.304C119.41 26.027 119.854 27.0222 120.638 27.7421C121.421 28.4621 122.385 28.822 123.528 28.822C125.18 28.822 126.355 28.1127 127.053 26.694H131.849C131.341 28.3879 130.367 29.7854 128.927 30.8865C127.488 31.9664 125.72 32.5063 123.623 32.5063C121.929 32.5063 120.405 32.1358 119.05 31.3947C117.716 30.6324 116.668 29.5631 115.905 28.1868C115.164 26.8105 114.794 25.2224 114.794 23.4226C114.794 21.6017 115.164 20.003 115.905 18.6267C116.646 17.2504 117.684 16.1917 119.018 15.4506C120.352 14.7095 121.887 14.3389 123.623 14.3389C125.296 14.3389 126.789 14.6989 128.102 15.4188C129.436 16.1387 130.462 17.1657 131.182 18.4996C131.924 19.8124 132.294 21.3264 132.294 23.0415ZM127.689 21.771C127.668 20.6276 127.255 19.7172 126.45 19.0396C125.645 18.3408 124.661 17.9915 123.496 17.9915C122.395 17.9915 121.464 18.3303 120.701 19.0078C119.96 19.6642 119.505 20.5853 119.336 21.771H127.689ZM141.955 32.5063C140.516 32.5063 139.224 32.2522 138.081 31.744C136.937 31.2147 136.027 30.5054 135.349 29.616C134.693 28.7267 134.333 27.7421 134.269 26.6623H138.748C138.832 27.3398 139.16 27.9009 139.732 28.3456C140.325 28.7903 141.055 29.0126 141.924 29.0126C142.771 29.0126 143.427 28.8432 143.893 28.5044C144.38 28.1656 144.623 27.7316 144.623 27.2022C144.623 26.6305 144.327 26.207 143.734 25.9318C143.162 25.6353 142.241 25.3177 140.971 | {
"end_byte": 5628,
"start_byte": 2208,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/assets/logo.svg_5629_6611 | 24.9789C139.658 24.6613 138.578 24.3331 137.731 23.9943C136.905 23.6555 136.185 23.1368 135.571 22.438C134.979 21.7393 134.682 20.797 134.682 19.6113C134.682 18.6373 134.957 17.748 135.508 16.9434C136.08 16.1387 136.884 15.5035 137.922 15.0377C138.98 14.5719 140.219 14.3389 141.638 14.3389C143.734 14.3389 145.407 14.8683 146.656 15.927C147.905 16.9645 148.593 18.3726 148.721 20.1512H144.465C144.401 19.4525 144.105 18.902 143.575 18.4996C143.067 18.0762 142.379 17.8644 141.511 17.8644C140.706 17.8644 140.081 18.0126 139.637 18.3091C139.213 18.6055 139.002 19.0184 139.002 19.5478C139.002 20.1406 139.298 20.5959 139.891 20.9135C140.484 21.2099 141.405 21.517 142.654 21.8346C143.925 22.1522 144.973 22.4804 145.798 22.8192C146.624 23.1579 147.334 23.6873 147.926 24.4072C148.541 25.106 148.858 26.0376 148.879 27.2022C148.879 28.2186 148.593 29.129 148.022 29.9337C147.471 30.7383 146.667 31.3735 145.608 31.8393C144.57 32.284 143.353 32.5063 141.955 32.5063Z" fill="#605DC8"/> | {
"end_byte": 6611,
"start_byte": 5629,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/assets/logo.svg_6612_6619 | </svg>
| {
"end_byte": 6619,
"start_byte": 6612,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/03-HousingLocation/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/README.md_0_5500 | # Creating an interface
This tutorial lesson demonstrates how to create an interface and include it in a component of your app.
<docs-video src="https://www.youtube.com/embed/eM3zi_n7lNs?si=YkFSeUeV8Ixtz8pm"/>
## What you'll learn
* Your app has a new interface that it can use as a data type.
* Your app has an instance of the new interface with sample data.
## Conceptual preview of interfaces
[Interfaces](https://www.typescriptlang.org/docs/handbook/interfaces.html) are custom data types for your app.
Angular uses TypeScript to take advantage of working in a strongly typed programming environment.
Strong type checking reduces the likelihood of one element in your app sending incorrectly formatted data to another.
Such type-mismatch errors are caught by the TypeScript compiler and many such errors can also be caught in your IDE.
In this lesson, you'll create an interface to define properties that represent data about a single housing location.
<docs-workflow>
<docs-step title="Create a new Angular interface">
This step creates a new interface in your app.
In the **Terminal** pane of your IDE:
1. In your project directory, navigate to the `first-app` directory.
1. In the `first-app` directory, run this command to create the new interface.
<docs-code language="shell">
ng generate interface housinglocation
</docs-code>
1. Run `ng serve` to build the app and serve it to `http://localhost:4200`.
1. In a browser, open `http://localhost:4200` to see your app.
1. Confirm that the app builds without error.
Correct any errors before you continue to the next step.
</docs-step>
<docs-step title="Add properties to the new interface">
This step adds the properties to the interface that your app needs to represent a housing location.
1. In the **Terminal** pane of your IDE, start the `ng serve` command, if it isn't already running, to build the app and serve it to `http://localhost:4200`.
1. In the **Edit** pane of your IDE, open the `src/app/housinglocation.ts` file.
1. In `housinglocation.ts`, replace the default content with the following code to make your new interface to match this example.
<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]" />
1. Save your changes and confirm the app does not display any errors. Correct any errors before you continue to the next step.
At this point, you've defined an interface that represents data about a housing location including an `id`, `name`, and location information.
</docs-step>
<docs-step title="Create a test house for your app">
You have an interface, but you aren't using it yet.
In this step, you create an instance of the interface and assign some sample data to it.
You won't see this sample data appear in your app yet.
There are a few more lessons to complete before that happens.
1. In the **Terminal** pane of your IDE, run the `ng serve` command, if it isn't already running, to build the app and serve your app to `http://localhost:4200`.
1. In the **Edit** pane of your IDE, open `src/app/home/home.component.ts`.
1. In `src/app/home/home.component.ts`, add this import statement after the existing `import` statements so that `HomeComponent` can use the new interface.
<docs-code header="Import HomeComponent in src/app/home/home.component.ts" path="adev/src/content/tutorials/first-app/steps/05-inputs/src/app/home/home.component.ts" visibleLines="[4]"/>
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.
<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]"/>
1. Confirm that your `home.component.ts` file matches like this example.
<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]" />
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.
1. Save your changes and confirm the app does not have any errors. Open the browser and confirm that your application still displays the message "housing-location works!"
<img alt="browser frame of homes-app displaying logo, filter text input box and search button and the message 'housing-location works!'" src="assets/images/tutorials/first-app/homes-app-lesson-03-step-2.png">
1. Correct any errors before you continue to the next step.
</docs-step>
</docs-workflow>
Summary: In this lesson, you created an interface that created a new data type for your app.
This new data type makes it possible for you to specify where `HousingLocation` data is required.
This new data type also makes it possible for your IDE and the TypeScript compiler can ensure that `HousingLocation` data is used where it's required.
For more information about the topics covered in this lesson, visit:
<docs-pill-row>
<docs-pill href="cli/generate/interface" title="ng generate interface"/>
<docs-pill href="cli/generate" title="ng generate"/>
</docs-pill-row>
| {
"end_byte": 5500,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/README.md"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/src/index.html_0_427 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Homes</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
</head>
<body>
<app-root></app-root>
</body>
</html>
| {
"end_byte": 427,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/src/index.html"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/src/main.ts_0_420 | /*
* Protractor support is deprecated in Angular.
* Protractor is used in this example for compatibility with Angular documentation tools.
*/
import {bootstrapApplication, provideProtractorTestingSupport} from '@angular/platform-browser';
import {AppComponent} from './app/app.component';
bootstrapApplication(AppComponent, {providers: [provideProtractorTestingSupport()]}).catch((err) =>
console.error(err),
);
| {
"end_byte": 420,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/src/main.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/src/styles.css_0_443 | /* You can add global styles to this file, and also import other style files */
* {
margin: 0;
padding: 0;
}
body {
font-family: 'Be Vietnam Pro', sans-serif;
}
:root {
--primary-color: #605DC8;
--secondary-color: #8B89E6;
--accent-color: #e8e7fa;
--shadow-color: #E8E8E8;
}
button.primary {
padding: 10px;
border: solid 1px var(--primary-color);
background: var(--primary-color);
color: white;
border-radius: 8px;
}
| {
"end_byte": 443,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/src/styles.css"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/app.component.ts_0_529 | import {Component} from '@angular/core';
import {HomeComponent} from './home/home.component';
@Component({
selector: 'app-root',
standalone: true,
imports: [HomeComponent],
template: `
<main>
<header class="brand-name">
<img class="brand-logo" src="/assets/logo.svg" alt="logo" aria-hidden="true" />
</header>
<section class="content">
<app-home></app-home>
</section>
</main>
`,
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'homes';
}
| {
"end_byte": 529,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/app.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/app.component.css_0_213 | :host {
--content-padding: 10px;
}
header {
display: block;
height: 60px;
padding: var(--content-padding);
box-shadow: 0px 5px 25px var(--shadow-color);
}
.content {
padding: var(--content-padding);
}
| {
"end_byte": 213,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/app.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/home/home.component.ts_0_651 | import {Component} from '@angular/core';
import {CommonModule} from '@angular/common';
import {HousingLocationComponent} from '../housing-location/housing-location.component';
@Component({
selector: 'app-home',
standalone: true,
imports: [CommonModule, HousingLocationComponent],
template: `
<section>
<form>
<input type="text" placeholder="Filter by city" />
<button class="primary" type="button">Search</button>
</form>
</section>
<section class="results">
<app-housing-location></app-housing-location>
</section>
`,
styleUrls: ['./home.component.css'],
})
export class HomeComponent {}
| {
"end_byte": 651,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/home/home.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/home/home.component.css_0_746 | .results {
display: grid;
column-gap: 14px;
row-gap: 14px;
grid-template-columns: repeat(auto-fill, minmax(400px, 400px));
margin-top: 50px;
justify-content: space-around;
}
input[type="text"] {
border: solid 1px var(--primary-color);
padding: 10px;
border-radius: 8px;
margin-right: 4px;
display: inline-block;
width: 30%;
}
button {
padding: 10px;
border: solid 1px var(--primary-color);
background: var(--primary-color);
color: white;
border-radius: 8px;
}
@media (min-width: 500px) and (max-width: 768px) {
.results {
grid-template-columns: repeat(2, 1fr);
}
input[type="text"] {
width: 70%;
}
}
@media (max-width: 499px) {
.results {
grid-template-columns: 1fr;
}
}
| {
"end_byte": 746,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/home/home.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/housing-location/housing-location.component.css_0_583 | .listing {
background: var(--accent-color);
border-radius: 30px;
padding-bottom: 30px;
}
.listing-heading {
color: var(--primary-color);
padding: 10px 20px 0 20px;
}
.listing-photo {
height: 250px;
width: 100%;
object-fit: cover;
border-radius: 30px 30px 0 0;
}
.listing-location {
padding: 10px 20px 20px 20px;
}
.listing-location::before {
content: url("/assets/location-pin.svg") / "";
}
section.listing a {
padding-left: 20px;
text-decoration: none;
color: var(--primary-color);
}
section.listing a::after {
content: "\203A";
margin-left: 5px;
}
| {
"end_byte": 583,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/housing-location/housing-location.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/housing-location/housing-location.component.ts_0_333 | import {Component} from '@angular/core';
import {CommonModule} from '@angular/common';
@Component({
selector: 'app-housing-location',
standalone: true,
imports: [CommonModule],
template: `
<p>housing-location works!</p>
`,
styleUrls: ['./housing-location.component.css'],
})
export class HousingLocationComponent {}
| {
"end_byte": 333,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/src/app/housing-location/housing-location.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/src/assets/location-pin.svg_0_502 | <?xml version="1.0" encoding="UTF-8"?>
<svg width="20pt" height="20pt" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<path d="m50 11.602c-15.398 0-27.898 12.5-27.898 27.898 0 5 1.3008 9.6992 3.6016 13.801l2.8984 4.1992 21.398 30.898 21.801-31.398 2.1992-3.1992c2.5-4.1992 3.8984-9 3.8984-14.199 0-15.5-12.5-28-27.898-28zm0 35.598c-4.1992 0-7.6992-3.3984-7.6992-7.6992s3.3984-7.6992 7.6992-7.6992 7.6992 3.3984 7.6992 7.6992-3.5 7.6992-7.6992 7.6992z" fill="#605cc8"/>
</svg>
| {
"end_byte": 502,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/src/assets/location-pin.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/src/assets/logo.svg_0_2207 | <svg width="151" height="44" viewBox="0 0 151 44" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.15532 33.2946C5.25369 33.2946 4.58006 32.5707 4.58006 31.6701V24.0152C4.58006 19.5469 4.35206 20.6276 7.59585 17.4236C21.7317 4.06732 16.2425 4.24744 29.6149 18.054C32.0434 20.7627 31.9985 19.4534 31.9985 23.8316V31.6667C31.9985 32.5707 31.28 33.2912 30.3749 33.2912H6.15532V33.2946Z" fill="#605DC8"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M30.896 35.1547L5.73676 35.2586C4.80059 35.2621 3.75042 35.8232 3.37388 36.5229L2.90061 37.4027L0.537726 41.7878L0.140457 42.529C-0.236085 43.2253 0.164639 43.7829 1.10081 43.7795L26.26 43.6756C27.1962 43.6721 28.2464 43.111 28.6229 42.4113L29.0962 41.5315L31.4591 37.1463L31.8563 36.4051C32.2329 35.7089 31.8321 35.1512 30.896 35.1547Z" fill="#605DC8"/>
<path d="M2.54861 18.7156C2.23079 18.7156 1.90952 18.629 1.6228 18.4454C0.821352 17.9363 0.5899 16.859 1.09771 16.0554C1.46389 15.4701 2.70061 14.2231 5.50912 11.4659L6.39693 10.5931C8.73218 8.38318 10.5147 6.56817 11.9449 5.10646C15.1679 1.81587 16.7985 0.153263 18.9023 0.222538C20.9888 0.277958 22.4362 1.92325 25.3138 5.19651C26.7267 6.8037 28.4816 8.8023 30.8514 11.2477C30.8652 11.265 30.8825 11.2789 30.8963 11.2962C31.228 11.6634 31.715 12.2003 32.2401 12.7752C33.9743 14.6734 34.8206 15.6086 35.0763 15.9688C35.629 16.7413 35.4494 17.8185 34.679 18.3727C33.9087 18.9234 32.8343 18.7468 32.2816 17.9744C32.0639 17.6869 30.5889 16.0693 29.708 15.1064C29.1863 14.5348 28.6993 14.0014 28.3642 13.6308C25.9495 11.1369 24.1704 9.11057 22.7368 7.4826C21.0233 5.5325 19.4032 3.68977 18.809 3.67245H18.8021C18.1699 3.67245 16.3356 5.54289 14.3976 7.52417C12.9467 9.00666 11.14 10.8494 8.78054 13.0766L7.91001 13.9321C6.74929 15.0717 4.33804 17.4375 3.97877 17.9293C3.65405 18.4454 3.10824 18.7225 2.54515 18.7225L2.54861 18.7156Z" fill="#605DC8"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.0976 33.2115V26.0588C22.0976 25.4665 21.6174 24.985 21.0267 24.985H15.1955C14.6047 24.985 14.1246 25.4665 14.1246 26.0588V33.2115C14.1246 33.2704 14.1142 33.3293 14.0969 33.3847H22.1252C22.1079 33.3293 22.0976 33.2739 22.0976 33.2115Z" fill="white"/> | {
"end_byte": 2207,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/src/assets/logo.svg_2208_5628 | <path d="M58.9784 10.0512V32.2205H54.5319V22.7874H45.0353V32.2205H40.5887V10.0512H45.0353V19.1666H54.5319V10.0512H58.9784ZM70.8506 32.5063C69.1567 32.5063 67.6322 32.1358 66.277 31.3947C64.9219 30.6324 63.8526 29.5631 63.0692 28.1868C62.3069 26.8105 61.9258 25.2224 61.9258 23.4226C61.9258 21.6228 62.3175 20.0348 63.1009 18.6585C63.9055 17.2821 64.996 16.2234 66.3723 15.4823C67.7486 14.7201 69.2838 14.3389 70.9777 14.3389C72.6716 14.3389 74.2067 14.7201 75.5831 15.4823C76.9594 16.2234 78.0393 17.2821 78.8227 18.6585C79.6273 20.0348 80.0296 21.6228 80.0296 23.4226C80.0296 25.2224 79.6167 26.8105 78.7909 28.1868C77.9863 29.5631 76.8853 30.6324 75.4878 31.3947C74.1115 32.1358 72.5657 32.5063 70.8506 32.5063ZM70.8506 28.6315C71.6553 28.6315 72.4069 28.4409 73.1057 28.0597C73.8256 27.6574 74.3973 27.0646 74.8208 26.2811C75.2443 25.4977 75.456 24.5449 75.456 23.4226C75.456 21.7499 75.0114 20.4688 74.122 19.5795C73.2539 18.669 72.1846 18.2138 70.9142 18.2138C69.6437 18.2138 68.5744 18.669 67.7063 19.5795C66.8593 20.4688 66.4358 21.7499 66.4358 23.4226C66.4358 25.0954 66.8487 26.387 67.6745 27.2975C68.5215 28.1868 69.5802 28.6315 70.8506 28.6315ZM104.825 14.3707C106.985 14.3707 108.721 15.0377 110.034 16.3717C111.368 17.6844 112.035 19.5266 112.035 21.8981V32.2205H107.589V22.5016C107.589 21.1252 107.239 20.0771 106.54 19.3572C105.842 18.6161 104.889 18.2456 103.682 18.2456C102.475 18.2456 101.512 18.6161 100.792 19.3572C100.093 20.0771 99.7436 21.1252 99.7436 22.5016V32.2205H95.297V22.5016C95.297 21.1252 94.9477 20.0771 94.2489 19.3572C93.5502 18.6161 92.5974 18.2456 91.3904 18.2456C90.1623 18.2456 89.1883 18.6161 88.4684 19.3572C87.7697 20.0771 87.4203 21.1252 87.4203 22.5016V32.2205H82.9737V14.6248H87.4203V16.7528C87.992 16.0117 88.7225 15.4294 89.6118 15.0059C90.5223 14.5824 91.5175 14.3707 92.5974 14.3707C93.9737 14.3707 95.2018 14.6671 96.2816 15.26C97.3615 15.8317 98.1979 16.6575 98.7908 17.7374C99.3625 16.721 100.188 15.9058 101.268 15.2918C102.369 14.6777 103.555 14.3707 104.825 14.3707ZM132.294 23.0415C132.294 23.6767 132.252 24.2484 132.167 24.7566H119.304C119.41 26.027 119.854 27.0222 120.638 27.7421C121.421 28.4621 122.385 28.822 123.528 28.822C125.18 28.822 126.355 28.1127 127.053 26.694H131.849C131.341 28.3879 130.367 29.7854 128.927 30.8865C127.488 31.9664 125.72 32.5063 123.623 32.5063C121.929 32.5063 120.405 32.1358 119.05 31.3947C117.716 30.6324 116.668 29.5631 115.905 28.1868C115.164 26.8105 114.794 25.2224 114.794 23.4226C114.794 21.6017 115.164 20.003 115.905 18.6267C116.646 17.2504 117.684 16.1917 119.018 15.4506C120.352 14.7095 121.887 14.3389 123.623 14.3389C125.296 14.3389 126.789 14.6989 128.102 15.4188C129.436 16.1387 130.462 17.1657 131.182 18.4996C131.924 19.8124 132.294 21.3264 132.294 23.0415ZM127.689 21.771C127.668 20.6276 127.255 19.7172 126.45 19.0396C125.645 18.3408 124.661 17.9915 123.496 17.9915C122.395 17.9915 121.464 18.3303 120.701 19.0078C119.96 19.6642 119.505 20.5853 119.336 21.771H127.689ZM141.955 32.5063C140.516 32.5063 139.224 32.2522 138.081 31.744C136.937 31.2147 136.027 30.5054 135.349 29.616C134.693 28.7267 134.333 27.7421 134.269 26.6623H138.748C138.832 27.3398 139.16 27.9009 139.732 28.3456C140.325 28.7903 141.055 29.0126 141.924 29.0126C142.771 29.0126 143.427 28.8432 143.893 28.5044C144.38 28.1656 144.623 27.7316 144.623 27.2022C144.623 26.6305 144.327 26.207 143.734 25.9318C143.162 25.6353 142.241 25.3177 140.971 | {
"end_byte": 5628,
"start_byte": 2208,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/src/assets/logo.svg_5629_6611 | 24.9789C139.658 24.6613 138.578 24.3331 137.731 23.9943C136.905 23.6555 136.185 23.1368 135.571 22.438C134.979 21.7393 134.682 20.797 134.682 19.6113C134.682 18.6373 134.957 17.748 135.508 16.9434C136.08 16.1387 136.884 15.5035 137.922 15.0377C138.98 14.5719 140.219 14.3389 141.638 14.3389C143.734 14.3389 145.407 14.8683 146.656 15.927C147.905 16.9645 148.593 18.3726 148.721 20.1512H144.465C144.401 19.4525 144.105 18.902 143.575 18.4996C143.067 18.0762 142.379 17.8644 141.511 17.8644C140.706 17.8644 140.081 18.0126 139.637 18.3091C139.213 18.6055 139.002 19.0184 139.002 19.5478C139.002 20.1406 139.298 20.5959 139.891 20.9135C140.484 21.2099 141.405 21.517 142.654 21.8346C143.925 22.1522 144.973 22.4804 145.798 22.8192C146.624 23.1579 147.334 23.6873 147.926 24.4072C148.541 25.106 148.858 26.0376 148.879 27.2022C148.879 28.2186 148.593 29.129 148.022 29.9337C147.471 30.7383 146.667 31.3735 145.608 31.8393C144.57 32.284 143.353 32.5063 141.955 32.5063Z" fill="#605DC8"/> | {
"end_byte": 6611,
"start_byte": 5629,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/04-interfaces/src/assets/logo.svg_6612_6619 | </svg>
| {
"end_byte": 6619,
"start_byte": 6612,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/04-interfaces/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/README.md_0_2357 | # Add a property binding to a component’s template
This tutorial lesson demonstrates how to add property binding to a template and use it to pass dynamic data to components.
<docs-video src="https://www.youtube.com/embed/eM3zi_n7lNs?si=AsiczpWnMz5HhJqB&start=599"/>
## What you'll learn
* Your app has data bindings in the `HomeComponent` template.
* Your app sends data from the `HomeComponent` to the `HousingLocationComponent`.
## Conceptual preview of Inputs
In this lesson, you'll continue the process of sharing data from the parent component to the child component by binding data to those properties in the template using property binding.
Property binding enables you to connect a variable to an `Input` in an Angular template. The data is then dynamically bound to the `Input`.
For a more in depth explanation, please refer to the [Property binding](guide/templates/property-binding) guide.
<docs-workflow>
<docs-step title="Update the `HomeComponent` template">
This step adds property binding to the `<app-housing-location>` tag.
In the code editor:
1. Navigate to `src/app/home/home.component.ts`
1. In the template property of the `@Component` decorator, update the code to match the code below:
<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]"/>
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.
The value on the right-hand side is the name of the property from the `HomeComponent`.
</docs-step>
<docs-step title="Confirm the code still works">
1. Save your changes and confirm the app does not have any errors.
1. Correct any errors before you continue to the next step.
</docs-step>
</docs-workflow>
Summary: In this lesson, you added a new property binding and passed in a reference to a class property. Now, the `HousingLocationComponent` has access to data that it can use to customize the component's display.
For more information about the topics covered in this lesson, visit:
<docs-pill-row>
<docs-pill href="guide/templates/property-binding" title="Property binding"/>
</docs-pill-row>
| {
"end_byte": 2357,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/README.md"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/index.html_0_427 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Homes</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
</head>
<body>
<app-root></app-root>
</body>
</html>
| {
"end_byte": 427,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/index.html"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/main.ts_0_420 | /*
* Protractor support is deprecated in Angular.
* Protractor is used in this example for compatibility with Angular documentation tools.
*/
import {bootstrapApplication, provideProtractorTestingSupport} from '@angular/platform-browser';
import {AppComponent} from './app/app.component';
bootstrapApplication(AppComponent, {providers: [provideProtractorTestingSupport()]}).catch((err) =>
console.error(err),
);
| {
"end_byte": 420,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/main.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/styles.css_0_443 | /* You can add global styles to this file, and also import other style files */
* {
margin: 0;
padding: 0;
}
body {
font-family: 'Be Vietnam Pro', sans-serif;
}
:root {
--primary-color: #605DC8;
--secondary-color: #8B89E6;
--accent-color: #e8e7fa;
--shadow-color: #E8E8E8;
}
button.primary {
padding: 10px;
border: solid 1px var(--primary-color);
background: var(--primary-color);
color: white;
border-radius: 8px;
}
| {
"end_byte": 443,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/styles.css"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/housinglocation.ts_0_180 | export interface HousingLocation {
id: number;
name: string;
city: string;
state: string;
photo: string;
availableUnits: number;
wifi: boolean;
laundry: boolean;
}
| {
"end_byte": 180,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/housinglocation.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/app.component.ts_0_529 | import {Component} from '@angular/core';
import {HomeComponent} from './home/home.component';
@Component({
selector: 'app-root',
standalone: true,
imports: [HomeComponent],
template: `
<main>
<header class="brand-name">
<img class="brand-logo" src="/assets/logo.svg" alt="logo" aria-hidden="true" />
</header>
<section class="content">
<app-home></app-home>
</section>
</main>
`,
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'homes';
}
| {
"end_byte": 529,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/app.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/app.component.css_0_213 | :host {
--content-padding: 10px;
}
header {
display: block;
height: 60px;
padding: var(--content-padding);
box-shadow: 0px 5px 25px var(--shadow-color);
}
.content {
padding: var(--content-padding);
}
| {
"end_byte": 213,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/app.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/home/home.component.ts_0_1010 | import {Component} from '@angular/core';
import {CommonModule} from '@angular/common';
import {HousingLocationComponent} from '../housing-location/housing-location.component';
import {HousingLocation} from '../housinglocation';
@Component({
selector: 'app-home',
standalone: true,
imports: [CommonModule, HousingLocationComponent],
template: `
<section>
<form>
<input type="text" placeholder="Filter by city" />
<button class="primary" type="button">Search</button>
</form>
</section>
<section class="results">
<app-housing-location></app-housing-location>
</section>
`,
styleUrls: ['./home.component.css'],
})
export class HomeComponent {
readonly baseUrl = 'https://angular.dev/assets/images/tutorials/common';
housingLocation: HousingLocation = {
id: 9999,
name: 'Test Home',
city: 'Test city',
state: 'ST',
photo: `${this.baseUrl}/example-house.jpg`,
availableUnits: 99,
wifi: true,
laundry: false,
};
}
| {
"end_byte": 1010,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/home/home.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/home/home.component.css_0_746 | .results {
display: grid;
column-gap: 14px;
row-gap: 14px;
grid-template-columns: repeat(auto-fill, minmax(400px, 400px));
margin-top: 50px;
justify-content: space-around;
}
input[type="text"] {
border: solid 1px var(--primary-color);
padding: 10px;
border-radius: 8px;
margin-right: 4px;
display: inline-block;
width: 30%;
}
button {
padding: 10px;
border: solid 1px var(--primary-color);
background: var(--primary-color);
color: white;
border-radius: 8px;
}
@media (min-width: 500px) and (max-width: 768px) {
.results {
grid-template-columns: repeat(2, 1fr);
}
input[type="text"] {
width: 70%;
}
}
@media (max-width: 499px) {
.results {
grid-template-columns: 1fr;
}
}
| {
"end_byte": 746,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/home/home.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/housing-location/housing-location.component.css_0_583 | .listing {
background: var(--accent-color);
border-radius: 30px;
padding-bottom: 30px;
}
.listing-heading {
color: var(--primary-color);
padding: 10px 20px 0 20px;
}
.listing-photo {
height: 250px;
width: 100%;
object-fit: cover;
border-radius: 30px 30px 0 0;
}
.listing-location {
padding: 10px 20px 20px 20px;
}
.listing-location::before {
content: url("/assets/location-pin.svg") / "";
}
section.listing a {
padding-left: 20px;
text-decoration: none;
color: var(--primary-color);
}
section.listing a::after {
content: "\203A";
margin-left: 5px;
}
| {
"end_byte": 583,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/housing-location/housing-location.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/housing-location/housing-location.component.ts_0_438 | import {Component, Input} from '@angular/core';
import {CommonModule} from '@angular/common';
import {HousingLocation} from '../housinglocation';
@Component({
selector: 'app-housing-location',
standalone: true,
imports: [CommonModule],
template: `
<p>housing-location works!</p>
`,
styleUrls: ['./housing-location.component.css'],
})
export class HousingLocationComponent {
@Input() housingLocation!: HousingLocation;
}
| {
"end_byte": 438,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/app/housing-location/housing-location.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/assets/location-pin.svg_0_502 | <?xml version="1.0" encoding="UTF-8"?>
<svg width="20pt" height="20pt" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<path d="m50 11.602c-15.398 0-27.898 12.5-27.898 27.898 0 5 1.3008 9.6992 3.6016 13.801l2.8984 4.1992 21.398 30.898 21.801-31.398 2.1992-3.1992c2.5-4.1992 3.8984-9 3.8984-14.199 0-15.5-12.5-28-27.898-28zm0 35.598c-4.1992 0-7.6992-3.3984-7.6992-7.6992s3.3984-7.6992 7.6992-7.6992 7.6992 3.3984 7.6992 7.6992-3.5 7.6992-7.6992 7.6992z" fill="#605cc8"/>
</svg>
| {
"end_byte": 502,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/assets/location-pin.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/assets/logo.svg_0_2207 | <svg width="151" height="44" viewBox="0 0 151 44" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.15532 33.2946C5.25369 33.2946 4.58006 32.5707 4.58006 31.6701V24.0152C4.58006 19.5469 4.35206 20.6276 7.59585 17.4236C21.7317 4.06732 16.2425 4.24744 29.6149 18.054C32.0434 20.7627 31.9985 19.4534 31.9985 23.8316V31.6667C31.9985 32.5707 31.28 33.2912 30.3749 33.2912H6.15532V33.2946Z" fill="#605DC8"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M30.896 35.1547L5.73676 35.2586C4.80059 35.2621 3.75042 35.8232 3.37388 36.5229L2.90061 37.4027L0.537726 41.7878L0.140457 42.529C-0.236085 43.2253 0.164639 43.7829 1.10081 43.7795L26.26 43.6756C27.1962 43.6721 28.2464 43.111 28.6229 42.4113L29.0962 41.5315L31.4591 37.1463L31.8563 36.4051C32.2329 35.7089 31.8321 35.1512 30.896 35.1547Z" fill="#605DC8"/>
<path d="M2.54861 18.7156C2.23079 18.7156 1.90952 18.629 1.6228 18.4454C0.821352 17.9363 0.5899 16.859 1.09771 16.0554C1.46389 15.4701 2.70061 14.2231 5.50912 11.4659L6.39693 10.5931C8.73218 8.38318 10.5147 6.56817 11.9449 5.10646C15.1679 1.81587 16.7985 0.153263 18.9023 0.222538C20.9888 0.277958 22.4362 1.92325 25.3138 5.19651C26.7267 6.8037 28.4816 8.8023 30.8514 11.2477C30.8652 11.265 30.8825 11.2789 30.8963 11.2962C31.228 11.6634 31.715 12.2003 32.2401 12.7752C33.9743 14.6734 34.8206 15.6086 35.0763 15.9688C35.629 16.7413 35.4494 17.8185 34.679 18.3727C33.9087 18.9234 32.8343 18.7468 32.2816 17.9744C32.0639 17.6869 30.5889 16.0693 29.708 15.1064C29.1863 14.5348 28.6993 14.0014 28.3642 13.6308C25.9495 11.1369 24.1704 9.11057 22.7368 7.4826C21.0233 5.5325 19.4032 3.68977 18.809 3.67245H18.8021C18.1699 3.67245 16.3356 5.54289 14.3976 7.52417C12.9467 9.00666 11.14 10.8494 8.78054 13.0766L7.91001 13.9321C6.74929 15.0717 4.33804 17.4375 3.97877 17.9293C3.65405 18.4454 3.10824 18.7225 2.54515 18.7225L2.54861 18.7156Z" fill="#605DC8"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.0976 33.2115V26.0588C22.0976 25.4665 21.6174 24.985 21.0267 24.985H15.1955C14.6047 24.985 14.1246 25.4665 14.1246 26.0588V33.2115C14.1246 33.2704 14.1142 33.3293 14.0969 33.3847H22.1252C22.1079 33.3293 22.0976 33.2739 22.0976 33.2115Z" fill="white"/> | {
"end_byte": 2207,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/assets/logo.svg_2208_5628 | <path d="M58.9784 10.0512V32.2205H54.5319V22.7874H45.0353V32.2205H40.5887V10.0512H45.0353V19.1666H54.5319V10.0512H58.9784ZM70.8506 32.5063C69.1567 32.5063 67.6322 32.1358 66.277 31.3947C64.9219 30.6324 63.8526 29.5631 63.0692 28.1868C62.3069 26.8105 61.9258 25.2224 61.9258 23.4226C61.9258 21.6228 62.3175 20.0348 63.1009 18.6585C63.9055 17.2821 64.996 16.2234 66.3723 15.4823C67.7486 14.7201 69.2838 14.3389 70.9777 14.3389C72.6716 14.3389 74.2067 14.7201 75.5831 15.4823C76.9594 16.2234 78.0393 17.2821 78.8227 18.6585C79.6273 20.0348 80.0296 21.6228 80.0296 23.4226C80.0296 25.2224 79.6167 26.8105 78.7909 28.1868C77.9863 29.5631 76.8853 30.6324 75.4878 31.3947C74.1115 32.1358 72.5657 32.5063 70.8506 32.5063ZM70.8506 28.6315C71.6553 28.6315 72.4069 28.4409 73.1057 28.0597C73.8256 27.6574 74.3973 27.0646 74.8208 26.2811C75.2443 25.4977 75.456 24.5449 75.456 23.4226C75.456 21.7499 75.0114 20.4688 74.122 19.5795C73.2539 18.669 72.1846 18.2138 70.9142 18.2138C69.6437 18.2138 68.5744 18.669 67.7063 19.5795C66.8593 20.4688 66.4358 21.7499 66.4358 23.4226C66.4358 25.0954 66.8487 26.387 67.6745 27.2975C68.5215 28.1868 69.5802 28.6315 70.8506 28.6315ZM104.825 14.3707C106.985 14.3707 108.721 15.0377 110.034 16.3717C111.368 17.6844 112.035 19.5266 112.035 21.8981V32.2205H107.589V22.5016C107.589 21.1252 107.239 20.0771 106.54 19.3572C105.842 18.6161 104.889 18.2456 103.682 18.2456C102.475 18.2456 101.512 18.6161 100.792 19.3572C100.093 20.0771 99.7436 21.1252 99.7436 22.5016V32.2205H95.297V22.5016C95.297 21.1252 94.9477 20.0771 94.2489 19.3572C93.5502 18.6161 92.5974 18.2456 91.3904 18.2456C90.1623 18.2456 89.1883 18.6161 88.4684 19.3572C87.7697 20.0771 87.4203 21.1252 87.4203 22.5016V32.2205H82.9737V14.6248H87.4203V16.7528C87.992 16.0117 88.7225 15.4294 89.6118 15.0059C90.5223 14.5824 91.5175 14.3707 92.5974 14.3707C93.9737 14.3707 95.2018 14.6671 96.2816 15.26C97.3615 15.8317 98.1979 16.6575 98.7908 17.7374C99.3625 16.721 100.188 15.9058 101.268 15.2918C102.369 14.6777 103.555 14.3707 104.825 14.3707ZM132.294 23.0415C132.294 23.6767 132.252 24.2484 132.167 24.7566H119.304C119.41 26.027 119.854 27.0222 120.638 27.7421C121.421 28.4621 122.385 28.822 123.528 28.822C125.18 28.822 126.355 28.1127 127.053 26.694H131.849C131.341 28.3879 130.367 29.7854 128.927 30.8865C127.488 31.9664 125.72 32.5063 123.623 32.5063C121.929 32.5063 120.405 32.1358 119.05 31.3947C117.716 30.6324 116.668 29.5631 115.905 28.1868C115.164 26.8105 114.794 25.2224 114.794 23.4226C114.794 21.6017 115.164 20.003 115.905 18.6267C116.646 17.2504 117.684 16.1917 119.018 15.4506C120.352 14.7095 121.887 14.3389 123.623 14.3389C125.296 14.3389 126.789 14.6989 128.102 15.4188C129.436 16.1387 130.462 17.1657 131.182 18.4996C131.924 19.8124 132.294 21.3264 132.294 23.0415ZM127.689 21.771C127.668 20.6276 127.255 19.7172 126.45 19.0396C125.645 18.3408 124.661 17.9915 123.496 17.9915C122.395 17.9915 121.464 18.3303 120.701 19.0078C119.96 19.6642 119.505 20.5853 119.336 21.771H127.689ZM141.955 32.5063C140.516 32.5063 139.224 32.2522 138.081 31.744C136.937 31.2147 136.027 30.5054 135.349 29.616C134.693 28.7267 134.333 27.7421 134.269 26.6623H138.748C138.832 27.3398 139.16 27.9009 139.732 28.3456C140.325 28.7903 141.055 29.0126 141.924 29.0126C142.771 29.0126 143.427 28.8432 143.893 28.5044C144.38 28.1656 144.623 27.7316 144.623 27.2022C144.623 26.6305 144.327 26.207 143.734 25.9318C143.162 25.6353 142.241 25.3177 140.971 | {
"end_byte": 5628,
"start_byte": 2208,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/assets/logo.svg_5629_6611 | 24.9789C139.658 24.6613 138.578 24.3331 137.731 23.9943C136.905 23.6555 136.185 23.1368 135.571 22.438C134.979 21.7393 134.682 20.797 134.682 19.6113C134.682 18.6373 134.957 17.748 135.508 16.9434C136.08 16.1387 136.884 15.5035 137.922 15.0377C138.98 14.5719 140.219 14.3389 141.638 14.3389C143.734 14.3389 145.407 14.8683 146.656 15.927C147.905 16.9645 148.593 18.3726 148.721 20.1512H144.465C144.401 19.4525 144.105 18.902 143.575 18.4996C143.067 18.0762 142.379 17.8644 141.511 17.8644C140.706 17.8644 140.081 18.0126 139.637 18.3091C139.213 18.6055 139.002 19.0184 139.002 19.5478C139.002 20.1406 139.298 20.5959 139.891 20.9135C140.484 21.2099 141.405 21.517 142.654 21.8346C143.925 22.1522 144.973 22.4804 145.798 22.8192C146.624 23.1579 147.334 23.6873 147.926 24.4072C148.541 25.106 148.858 26.0376 148.879 27.2022C148.879 28.2186 148.593 29.129 148.022 29.9337C147.471 30.7383 146.667 31.3735 145.608 31.8393C144.57 32.284 143.353 32.5063 141.955 32.5063Z" fill="#605DC8"/> | {
"end_byte": 6611,
"start_byte": 5629,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/06-property-binding/src/assets/logo.svg_6612_6619 | </svg>
| {
"end_byte": 6619,
"start_byte": 6612,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/06-property-binding/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/README.md_0_6104 | # Adding a form to your Angular app
This tutorial lesson demonstrates how to add a form that collects user data to an Angular app.
This lesson starts with a functional Angular app and shows how to add a form to it.
The data that the form collects is sent only to the app's service, which writes it to the browser's console.
Using a REST API to send and receive the form's data is not covered in this lesson.
<docs-video src="https://www.youtube.com/embed/kWbk-dOJaNQ?si=FYMXGdUiT-qh321h"/>
IMPORTANT: We recommend using your local environment for this step of the tutorial.
## What you'll learn
- Your app has a form into which users can enter data that is sent to your app's service.
- The service writes the data from the form to the browser's console log.
<docs-workflow>
<docs-step title="Add a method to send form data">
This step adds a method to your app's service that receives the form data to send to the data's destination.
In this example, the method writes the data from the form to the browser's console log.
In the **Edit** pane of your IDE:
1. In `src/app/housing.service.ts`, inside the `HousingService` class, paste this method at the bottom of the class definition.
<docs-code header="Submit method in src/app/housing.service.ts" path="adev/src/content/tutorials/first-app/steps/13-search/src/app/housing.service.ts" visibleLines="[120,124]"/>
1. Confirm that the app builds without error.
Correct any errors before you continue to the next step.
</docs-step>
<docs-step title="Add the form functions to the details page">
This step adds the code to the details page that handles the form's interactions.
In the **Edit** pane of your IDE, in `src/app/details/details.component.ts`:
1. After the `import` statements at the top of the file, add the following code to import the Angular form classes.
<docs-code header="Forms imports in src/app/details/details.component.ts" path="adev/src/content/tutorials/first-app/steps/13-search/src/app/details/details.component.ts" visibleLines="[6]"/>
1. In the `DetailsComponent` decorator metadata, update the `imports` property with the following code:
<docs-code header="imports directive in src/app/details/details.component.ts" path="adev/src/content/tutorials/first-app/steps/13-search/src/app/details/details.component.ts" visibleLines="[10]"/>
1. In the `DetailsComponent` class, before the `constructor()` method, add the following code to create the form object.
<docs-code header="template directive in src/app/details/details.component.ts" path="adev/src/content/tutorials/first-app/steps/13-search/src/app/details/details.component.ts" visibleLines="[53,57]"/>
In Angular, `FormGroup` and `FormControl` are types that enable you to build forms. The `FormControl` type can provide a default value and shape the form data. In this example `firstName` is a `string` and the default value is empty string.
1. In the `DetailsComponent` class, after the `constructor()` method, add the following code to handle the **Apply now** click.
<docs-code header="template directive in src/app/details/details.component.ts" path="adev/src/content/tutorials/first-app/steps/13-search/src/app/details/details.component.ts" visibleLines="[63,69]"/>
This button does not exist yet - you will add it in the next step. In the above code, the `FormControl`s may return `null`. This code uses the nullish coalescing operator to default to empty string if the value is `null`.
1. Confirm that the app builds without error.
Correct any errors before you continue to the next step.
</docs-step>
<docs-step title="Add the form's markup to the details page">
This step adds the markup to the details page that displays the form.
In the **Edit** pane of your IDE, in `src/app/details/details.component.ts`:
1. In the `DetailsComponent` decorator metadata, update the `template` HTML to match the following code to add the form's markup.
<docs-code header="template directive in src/app/details/details.component.ts" path="adev/src/content/tutorials/first-app/steps/13-search/src/app/details/details.component.ts" visibleLines="[11,46]"/>
The template now includes an event handler `(submit)="submitApplication()"`. Angular uses parentheses syntax around the event name to define events in the template code. The code on the right hand side of the equals sign is the code that should be executed when this event is triggered. You can bind to browser events and custom events.
1. Confirm that the app builds without error.
Correct any errors before you continue to the next step.
<img alt="details page with a form for applying to live at this location" src="assets/images/tutorials/first-app/homes-app-lesson-12-step-3.png">
</docs-step>
<docs-step title="Test your app's new form">
This step tests the new form to see that when the form data is submitted to the app, the form data appears in the console log.
1. In the **Terminal** pane of your IDE, run `ng serve`, if it isn't already running.
1. In your browser, open your app at `http://localhost:4200`.
1. Right click on the app in the browser and from the context menu, choose **Inspect**.
1. In the developer tools window, choose the **Console** tab.
Make sure that the developer tools window is visible for the next steps
1. In your app:
1. Select a housing location and click **Learn more**, to see details about the house.
1. In the house's details page, scroll to the bottom to find the new form.
1. Enter data into the form's fields - any data is fine.
1. Choose **Apply now** to submit the data.
1. In the developer tools window, review the log output to find your form data.
</docs-step>
</docs-workflow>
Summary: In this lesson, you updated your app to add a form using Angular's forms feature, and connect the data captured in the form to a component using an event handler.
For more information about the topics covered in this lesson, visit:
<docs-pill-row>
<docs-pill href="guide/forms" title="Angular Forms"/>
<docs-pill href="guide/templates/event-listeners" title="Event Handling"/>
</docs-pill-row>
| {
"end_byte": 6104,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/README.md"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/index.html_0_427 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Homes</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
</head>
<body>
<app-root></app-root>
</body>
</html>
| {
"end_byte": 427,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/index.html"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/main.ts_0_536 | /*
* Protractor support is deprecated in Angular.
* Protractor is used in this example for compatibility with Angular documentation tools.
*/
import {bootstrapApplication, provideProtractorTestingSupport} from '@angular/platform-browser';
import {AppComponent} from './app/app.component';
import {provideRouter} from '@angular/router';
import routeConfig from './app/routes';
bootstrapApplication(AppComponent, {
providers: [provideProtractorTestingSupport(), provideRouter(routeConfig)],
}).catch((err) => console.error(err));
| {
"end_byte": 536,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/main.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/styles.css_0_443 | /* You can add global styles to this file, and also import other style files */
* {
margin: 0;
padding: 0;
}
body {
font-family: 'Be Vietnam Pro', sans-serif;
}
:root {
--primary-color: #605DC8;
--secondary-color: #8B89E6;
--accent-color: #e8e7fa;
--shadow-color: #E8E8E8;
}
button.primary {
padding: 10px;
border: solid 1px var(--primary-color);
background: var(--primary-color);
color: white;
border-radius: 8px;
}
| {
"end_byte": 443,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/styles.css"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/app/routes.ts_0_389 | import {Routes} from '@angular/router';
import {HomeComponent} from './home/home.component';
import {DetailsComponent} from './details/details.component';
const routeConfig: Routes = [
{
path: '',
component: HomeComponent,
title: 'Home page',
},
{
path: 'details/:id',
component: DetailsComponent,
title: 'Home details',
},
];
export default routeConfig;
| {
"end_byte": 389,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/app/routes.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/app/housinglocation.ts_0_180 | export interface HousingLocation {
id: number;
name: string;
city: string;
state: string;
photo: string;
availableUnits: number;
wifi: boolean;
laundry: boolean;
}
| {
"end_byte": 180,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/app/housinglocation.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/app/housing.service.ts_0_2978 | import {Injectable} from '@angular/core';
import {HousingLocation} from './housinglocation';
@Injectable({
providedIn: 'root',
})
export class HousingService {
readonly baseUrl = 'https://angular.dev/assets/images/tutorials/common';
protected housingLocationList: HousingLocation[] = [
{
id: 0,
name: 'Acme Fresh Start Housing',
city: 'Chicago',
state: 'IL',
photo: `${this.baseUrl}/bernard-hermant-CLKGGwIBTaY-unsplash.jpg`,
availableUnits: 4,
wifi: true,
laundry: true,
},
{
id: 1,
name: 'A113 Transitional Housing',
city: 'Santa Monica',
state: 'CA',
photo: `${this.baseUrl}/brandon-griggs-wR11KBaB86U-unsplash.jpg`,
availableUnits: 0,
wifi: false,
laundry: true,
},
{
id: 2,
name: 'Warm Beds Housing Support',
city: 'Juneau',
state: 'AK',
photo: `${this.baseUrl}/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: `${this.baseUrl}/ian-macdonald-W8z6aiwfi1E-unsplash.jpg`,
availableUnits: 1,
wifi: true,
laundry: false,
},
{
id: 4,
name: 'Happy Homes Group',
city: 'Gary',
state: 'IN',
photo: `${this.baseUrl}/krzysztof-hepner-978RAXoXnH4-unsplash.jpg`,
availableUnits: 1,
wifi: true,
laundry: false,
},
{
id: 5,
name: 'Hopeful Apartment Group',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/r-architecture-JvQ0Q5IkeMM-unsplash.jpg`,
availableUnits: 2,
wifi: true,
laundry: true,
},
{
id: 6,
name: 'Seriously Safe Towns',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/phil-hearing-IYfp2Ixe9nM-unsplash.jpg`,
availableUnits: 5,
wifi: true,
laundry: true,
},
{
id: 7,
name: 'Hopeful Housing Solutions',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/r-architecture-GGupkreKwxA-unsplash.jpg`,
availableUnits: 2,
wifi: true,
laundry: true,
},
{
id: 8,
name: 'Seriously Safe Towns',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/saru-robert-9rP3mxf8qWI-unsplash.jpg`,
availableUnits: 10,
wifi: false,
laundry: false,
},
{
id: 9,
name: 'Capital Safe Towns',
city: 'Portland',
state: 'OR',
photo: `${this.baseUrl}/webaliser-_TPTXZd9mOo-unsplash.jpg`,
availableUnits: 6,
wifi: true,
laundry: true,
},
];
getAllHousingLocations(): HousingLocation[] {
return this.housingLocationList;
}
getHousingLocationById(id: number): HousingLocation | undefined {
return this.housingLocationList.find((housingLocation) => housingLocation.id === id);
}
}
| {
"end_byte": 2978,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/app/housing.service.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/app/app.component.ts_0_671 | import {Component} from '@angular/core';
import {HomeComponent} from './home/home.component';
import {RouterLink, RouterOutlet} from '@angular/router';
@Component({
selector: 'app-root',
standalone: true,
imports: [HomeComponent, RouterLink, RouterOutlet],
template: `
<main>
<a [routerLink]="['/']">
<header class="brand-name">
<img class="brand-logo" src="/assets/logo.svg" alt="logo" aria-hidden="true" />
</header>
</a>
<section class="content">
<router-outlet></router-outlet>
</section>
</main>
`,
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'homes';
}
| {
"end_byte": 671,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/app/app.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/app/app.component.css_0_213 | :host {
--content-padding: 10px;
}
header {
display: block;
height: 60px;
padding: var(--content-padding);
box-shadow: 0px 5px 25px var(--shadow-color);
}
.content {
padding: var(--content-padding);
}
| {
"end_byte": 213,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/app/app.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/app/home/home.component.ts_0_1081 | import {Component, inject} from '@angular/core';
import {CommonModule} from '@angular/common';
import {HousingLocationComponent} from '../housing-location/housing-location.component';
import {HousingLocation} from '../housinglocation';
import {HousingService} from '../housing.service';
@Component({
selector: 'app-home',
standalone: true,
imports: [CommonModule, HousingLocationComponent],
template: `
<section>
<form>
<input type="text" placeholder="Filter by city" />
<button class="primary" type="button">Search</button>
</form>
</section>
<section class="results">
<app-housing-location
*ngFor="let housingLocation of housingLocationList"
[housingLocation]="housingLocation"
></app-housing-location>
</section>
`,
styleUrls: ['./home.component.css'],
})
export class HomeComponent {
housingLocationList: HousingLocation[] = [];
housingService: HousingService = inject(HousingService);
constructor() {
this.housingLocationList = this.housingService.getAllHousingLocations();
}
}
| {
"end_byte": 1081,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/app/home/home.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/app/home/home.component.css_0_746 | .results {
display: grid;
column-gap: 14px;
row-gap: 14px;
grid-template-columns: repeat(auto-fill, minmax(400px, 400px));
margin-top: 50px;
justify-content: space-around;
}
input[type="text"] {
border: solid 1px var(--primary-color);
padding: 10px;
border-radius: 8px;
margin-right: 4px;
display: inline-block;
width: 30%;
}
button {
padding: 10px;
border: solid 1px var(--primary-color);
background: var(--primary-color);
color: white;
border-radius: 8px;
}
@media (min-width: 500px) and (max-width: 768px) {
.results {
grid-template-columns: repeat(2, 1fr);
}
input[type="text"] {
width: 70%;
}
}
@media (max-width: 499px) {
.results {
grid-template-columns: 1fr;
}
}
| {
"end_byte": 746,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/app/home/home.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/app/housing-location/housing-location.component.css_0_583 | .listing {
background: var(--accent-color);
border-radius: 30px;
padding-bottom: 30px;
}
.listing-heading {
color: var(--primary-color);
padding: 10px 20px 0 20px;
}
.listing-photo {
height: 250px;
width: 100%;
object-fit: cover;
border-radius: 30px 30px 0 0;
}
.listing-location {
padding: 10px 20px 20px 20px;
}
.listing-location::before {
content: url("/assets/location-pin.svg") / "";
}
section.listing a {
padding-left: 20px;
text-decoration: none;
color: var(--primary-color);
}
section.listing a::after {
content: "\203A";
margin-left: 5px;
}
| {
"end_byte": 583,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/app/housing-location/housing-location.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/app/housing-location/housing-location.component.ts_0_908 | import {Component, Input} from '@angular/core';
import {CommonModule} from '@angular/common';
import {HousingLocation} from '../housinglocation';
import {RouterModule} from '@angular/router';
@Component({
selector: 'app-housing-location',
standalone: true,
imports: [CommonModule, RouterModule],
template: `
<section class="listing">
<img
class="listing-photo"
[src]="housingLocation.photo"
alt="Exterior photo of {{ housingLocation.name }}"
crossorigin
/>
<h2 class="listing-heading">{{ housingLocation.name }}</h2>
<p class="listing-location">{{ housingLocation.city }}, {{ housingLocation.state }}</p>
<a [routerLink]="['/details', housingLocation.id]">Learn More</a>
</section>
`,
styleUrls: ['./housing-location.component.css'],
})
export class HousingLocationComponent {
@Input() housingLocation!: HousingLocation;
}
| {
"end_byte": 908,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/app/housing-location/housing-location.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/app/details/details.component.ts_0_1572 | import {Component, inject} from '@angular/core';
import {CommonModule} from '@angular/common';
import {ActivatedRoute} from '@angular/router';
import {HousingService} from '../housing.service';
import {HousingLocation} from '../housinglocation';
@Component({
selector: 'app-details',
standalone: true,
imports: [CommonModule],
template: `
<article>
<img
class="listing-photo"
[src]="housingLocation?.photo"
alt="Exterior photo of {{ housingLocation?.name }}"
crossorigin
/>
<section class="listing-description">
<h2 class="listing-heading">{{ housingLocation?.name }}</h2>
<p class="listing-location">{{ housingLocation?.city }}, {{ housingLocation?.state }}</p>
</section>
<section class="listing-features">
<h2 class="section-heading">About this housing location</h2>
<ul>
<li>Units available: {{ housingLocation?.availableUnits }}</li>
<li>Does this location have wifi: {{ housingLocation?.wifi }}</li>
<li>Does this location have laundry: {{ housingLocation?.laundry }}</li>
</ul>
</section>
</article>
`,
styleUrls: ['./details.component.css'],
})
export class DetailsComponent {
route: ActivatedRoute = inject(ActivatedRoute);
housingService = inject(HousingService);
housingLocation: HousingLocation | undefined;
constructor() {
const housingLocationId = Number(this.route.snapshot.params['id']);
this.housingLocation = this.housingService.getHousingLocationById(housingLocationId);
}
}
| {
"end_byte": 1572,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/app/details/details.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/app/details/details.component.css_0_1075 | .listing-photo {
height: 600px;
width: 50%;
object-fit: cover;
border-radius: 30px;
float: right;
}
.listing-heading {
font-size: 48pt;
font-weight: bold;
margin-bottom: 15px;
}
.listing-location::before {
content: url('/assets/location-pin.svg') / '';
}
.listing-location {
font-size: 24pt;
margin-bottom: 15px;
}
.listing-features > .section-heading {
color: var(--secondary-color);
font-size: 24pt;
margin-bottom: 15px;
}
.listing-features {
margin-bottom: 20px;
}
.listing-features li {
font-size: 14pt;
}
li {
list-style-type: none;
}
.listing-apply .section-heading {
font-size: 18pt;
margin-bottom: 15px;
}
label, input {
display: block;
}
label {
color: var(--secondary-color);
font-weight: bold;
text-transform: uppercase;
font-size: 12pt;
}
input {
font-size: 16pt;
margin-bottom: 15px;
padding: 10px;
width: 400px;
border-top: none;
border-right: none;
border-left: none;
border-bottom: solid .3px;
}
@media (max-width: 1024px) {
.listing-photo {
width: 100%;
height: 400px;
}
}
| {
"end_byte": 1075,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/app/details/details.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/assets/location-pin.svg_0_502 | <?xml version="1.0" encoding="UTF-8"?>
<svg width="20pt" height="20pt" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<path d="m50 11.602c-15.398 0-27.898 12.5-27.898 27.898 0 5 1.3008 9.6992 3.6016 13.801l2.8984 4.1992 21.398 30.898 21.801-31.398 2.1992-3.1992c2.5-4.1992 3.8984-9 3.8984-14.199 0-15.5-12.5-28-27.898-28zm0 35.598c-4.1992 0-7.6992-3.3984-7.6992-7.6992s3.3984-7.6992 7.6992-7.6992 7.6992 3.3984 7.6992 7.6992-3.5 7.6992-7.6992 7.6992z" fill="#605cc8"/>
</svg>
| {
"end_byte": 502,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/assets/location-pin.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/assets/logo.svg_0_2207 | <svg width="151" height="44" viewBox="0 0 151 44" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.15532 33.2946C5.25369 33.2946 4.58006 32.5707 4.58006 31.6701V24.0152C4.58006 19.5469 4.35206 20.6276 7.59585 17.4236C21.7317 4.06732 16.2425 4.24744 29.6149 18.054C32.0434 20.7627 31.9985 19.4534 31.9985 23.8316V31.6667C31.9985 32.5707 31.28 33.2912 30.3749 33.2912H6.15532V33.2946Z" fill="#605DC8"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M30.896 35.1547L5.73676 35.2586C4.80059 35.2621 3.75042 35.8232 3.37388 36.5229L2.90061 37.4027L0.537726 41.7878L0.140457 42.529C-0.236085 43.2253 0.164639 43.7829 1.10081 43.7795L26.26 43.6756C27.1962 43.6721 28.2464 43.111 28.6229 42.4113L29.0962 41.5315L31.4591 37.1463L31.8563 36.4051C32.2329 35.7089 31.8321 35.1512 30.896 35.1547Z" fill="#605DC8"/>
<path d="M2.54861 18.7156C2.23079 18.7156 1.90952 18.629 1.6228 18.4454C0.821352 17.9363 0.5899 16.859 1.09771 16.0554C1.46389 15.4701 2.70061 14.2231 5.50912 11.4659L6.39693 10.5931C8.73218 8.38318 10.5147 6.56817 11.9449 5.10646C15.1679 1.81587 16.7985 0.153263 18.9023 0.222538C20.9888 0.277958 22.4362 1.92325 25.3138 5.19651C26.7267 6.8037 28.4816 8.8023 30.8514 11.2477C30.8652 11.265 30.8825 11.2789 30.8963 11.2962C31.228 11.6634 31.715 12.2003 32.2401 12.7752C33.9743 14.6734 34.8206 15.6086 35.0763 15.9688C35.629 16.7413 35.4494 17.8185 34.679 18.3727C33.9087 18.9234 32.8343 18.7468 32.2816 17.9744C32.0639 17.6869 30.5889 16.0693 29.708 15.1064C29.1863 14.5348 28.6993 14.0014 28.3642 13.6308C25.9495 11.1369 24.1704 9.11057 22.7368 7.4826C21.0233 5.5325 19.4032 3.68977 18.809 3.67245H18.8021C18.1699 3.67245 16.3356 5.54289 14.3976 7.52417C12.9467 9.00666 11.14 10.8494 8.78054 13.0766L7.91001 13.9321C6.74929 15.0717 4.33804 17.4375 3.97877 17.9293C3.65405 18.4454 3.10824 18.7225 2.54515 18.7225L2.54861 18.7156Z" fill="#605DC8"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.0976 33.2115V26.0588C22.0976 25.4665 21.6174 24.985 21.0267 24.985H15.1955C14.6047 24.985 14.1246 25.4665 14.1246 26.0588V33.2115C14.1246 33.2704 14.1142 33.3293 14.0969 33.3847H22.1252C22.1079 33.3293 22.0976 33.2739 22.0976 33.2115Z" fill="white"/> | {
"end_byte": 2207,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/assets/logo.svg_2208_5628 | <path d="M58.9784 10.0512V32.2205H54.5319V22.7874H45.0353V32.2205H40.5887V10.0512H45.0353V19.1666H54.5319V10.0512H58.9784ZM70.8506 32.5063C69.1567 32.5063 67.6322 32.1358 66.277 31.3947C64.9219 30.6324 63.8526 29.5631 63.0692 28.1868C62.3069 26.8105 61.9258 25.2224 61.9258 23.4226C61.9258 21.6228 62.3175 20.0348 63.1009 18.6585C63.9055 17.2821 64.996 16.2234 66.3723 15.4823C67.7486 14.7201 69.2838 14.3389 70.9777 14.3389C72.6716 14.3389 74.2067 14.7201 75.5831 15.4823C76.9594 16.2234 78.0393 17.2821 78.8227 18.6585C79.6273 20.0348 80.0296 21.6228 80.0296 23.4226C80.0296 25.2224 79.6167 26.8105 78.7909 28.1868C77.9863 29.5631 76.8853 30.6324 75.4878 31.3947C74.1115 32.1358 72.5657 32.5063 70.8506 32.5063ZM70.8506 28.6315C71.6553 28.6315 72.4069 28.4409 73.1057 28.0597C73.8256 27.6574 74.3973 27.0646 74.8208 26.2811C75.2443 25.4977 75.456 24.5449 75.456 23.4226C75.456 21.7499 75.0114 20.4688 74.122 19.5795C73.2539 18.669 72.1846 18.2138 70.9142 18.2138C69.6437 18.2138 68.5744 18.669 67.7063 19.5795C66.8593 20.4688 66.4358 21.7499 66.4358 23.4226C66.4358 25.0954 66.8487 26.387 67.6745 27.2975C68.5215 28.1868 69.5802 28.6315 70.8506 28.6315ZM104.825 14.3707C106.985 14.3707 108.721 15.0377 110.034 16.3717C111.368 17.6844 112.035 19.5266 112.035 21.8981V32.2205H107.589V22.5016C107.589 21.1252 107.239 20.0771 106.54 19.3572C105.842 18.6161 104.889 18.2456 103.682 18.2456C102.475 18.2456 101.512 18.6161 100.792 19.3572C100.093 20.0771 99.7436 21.1252 99.7436 22.5016V32.2205H95.297V22.5016C95.297 21.1252 94.9477 20.0771 94.2489 19.3572C93.5502 18.6161 92.5974 18.2456 91.3904 18.2456C90.1623 18.2456 89.1883 18.6161 88.4684 19.3572C87.7697 20.0771 87.4203 21.1252 87.4203 22.5016V32.2205H82.9737V14.6248H87.4203V16.7528C87.992 16.0117 88.7225 15.4294 89.6118 15.0059C90.5223 14.5824 91.5175 14.3707 92.5974 14.3707C93.9737 14.3707 95.2018 14.6671 96.2816 15.26C97.3615 15.8317 98.1979 16.6575 98.7908 17.7374C99.3625 16.721 100.188 15.9058 101.268 15.2918C102.369 14.6777 103.555 14.3707 104.825 14.3707ZM132.294 23.0415C132.294 23.6767 132.252 24.2484 132.167 24.7566H119.304C119.41 26.027 119.854 27.0222 120.638 27.7421C121.421 28.4621 122.385 28.822 123.528 28.822C125.18 28.822 126.355 28.1127 127.053 26.694H131.849C131.341 28.3879 130.367 29.7854 128.927 30.8865C127.488 31.9664 125.72 32.5063 123.623 32.5063C121.929 32.5063 120.405 32.1358 119.05 31.3947C117.716 30.6324 116.668 29.5631 115.905 28.1868C115.164 26.8105 114.794 25.2224 114.794 23.4226C114.794 21.6017 115.164 20.003 115.905 18.6267C116.646 17.2504 117.684 16.1917 119.018 15.4506C120.352 14.7095 121.887 14.3389 123.623 14.3389C125.296 14.3389 126.789 14.6989 128.102 15.4188C129.436 16.1387 130.462 17.1657 131.182 18.4996C131.924 19.8124 132.294 21.3264 132.294 23.0415ZM127.689 21.771C127.668 20.6276 127.255 19.7172 126.45 19.0396C125.645 18.3408 124.661 17.9915 123.496 17.9915C122.395 17.9915 121.464 18.3303 120.701 19.0078C119.96 19.6642 119.505 20.5853 119.336 21.771H127.689ZM141.955 32.5063C140.516 32.5063 139.224 32.2522 138.081 31.744C136.937 31.2147 136.027 30.5054 135.349 29.616C134.693 28.7267 134.333 27.7421 134.269 26.6623H138.748C138.832 27.3398 139.16 27.9009 139.732 28.3456C140.325 28.7903 141.055 29.0126 141.924 29.0126C142.771 29.0126 143.427 28.8432 143.893 28.5044C144.38 28.1656 144.623 27.7316 144.623 27.2022C144.623 26.6305 144.327 26.207 143.734 25.9318C143.162 25.6353 142.241 25.3177 140.971 | {
"end_byte": 5628,
"start_byte": 2208,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/assets/logo.svg_5629_6611 | 24.9789C139.658 24.6613 138.578 24.3331 137.731 23.9943C136.905 23.6555 136.185 23.1368 135.571 22.438C134.979 21.7393 134.682 20.797 134.682 19.6113C134.682 18.6373 134.957 17.748 135.508 16.9434C136.08 16.1387 136.884 15.5035 137.922 15.0377C138.98 14.5719 140.219 14.3389 141.638 14.3389C143.734 14.3389 145.407 14.8683 146.656 15.927C147.905 16.9645 148.593 18.3726 148.721 20.1512H144.465C144.401 19.4525 144.105 18.902 143.575 18.4996C143.067 18.0762 142.379 17.8644 141.511 17.8644C140.706 17.8644 140.081 18.0126 139.637 18.3091C139.213 18.6055 139.002 19.0184 139.002 19.5478C139.002 20.1406 139.298 20.5959 139.891 20.9135C140.484 21.2099 141.405 21.517 142.654 21.8346C143.925 22.1522 144.973 22.4804 145.798 22.8192C146.624 23.1579 147.334 23.6873 147.926 24.4072C148.541 25.106 148.858 26.0376 148.879 27.2022C148.879 28.2186 148.593 29.129 148.022 29.9337C147.471 30.7383 146.667 31.3735 145.608 31.8393C144.57 32.284 143.353 32.5063 141.955 32.5063Z" fill="#605DC8"/> | {
"end_byte": 6611,
"start_byte": 5629,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/12-forms/src/assets/logo.svg_6612_6619 | </svg>
| {
"end_byte": 6619,
"start_byte": 6612,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/12-forms/src/assets/logo.svg"
} |
angular/adev/src/content/tutorials/first-app/steps/13-search/README.md_0_4598 | # Add the search feature to your app
This tutorial lesson demonstrates how to add a search functionality to your Angular app.
The app will enable users to search through the data provided by your app and display only the results that match the entered term.
<docs-video src="https://www.youtube.com/embed/5K10oYJ5Y-E?si=TiuNKx_teR9baO7k&start=457"/>
IMPORTANT: We recommend using your local environment for this step of the tutorial.
## What you'll learn
- Your app will use data from a form to search for matching housing locations
- Your app will display only the matching housing locations
<docs-workflow>
<docs-step title="Update the home component properties">
In this step, you'll update the `HomeComponent` class to store data in a new array property that you will use for filtering.
1. In `src/app/home/home.component.ts`, add new property to the class called `filteredLocationList`.
<docs-code header="Add the filtered results property" path="adev/src/content/tutorials/first-app/steps/14-http/src/app/home/home.component.ts" visibleLines="[30]"/>
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 `HomeComponent` to set the value.
<docs-code header="Set the value of filteredLocationList" path="adev/src/content/tutorials/first-app/steps/14-http/src/app/home/home.component.ts" visibleLines="[31,34]"/>
</docs-step>
<docs-step title="Update the home component template">
The `HomeComponent` already contains an input field that you will use to capture input from the user. That string text will be used to filter the results.
1. Update the `HomeComponent` template to include a template variable in the `input` element called `#filter`.
<docs-code header="Add a template variable to HomeComponent's template" language="html">
<input type="text" placeholder="Filter by city" #filter>
</docs-code>
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.
<docs-code header="Bind the click event" language="html">
<button class="primary" type="button" (click)="filterResults(filter.value)">Search</button>
</docs-code>
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.
<docs-code header="Update the ngFor directive value" language="html">
<app-housing-location *ngFor="let housingLocation of filteredLocationList" [housingLocation]="housingLocation"></app-housing-location>
</docs-code>
</docs-step>
<docs-step title="Implement the event handler function">
The template has been updated to bind the `filterResults` function to the `click` event. Next, your task is to implement the `filterResults` function in the `HomeComponent` class.
1. Update the `HomeComponent` class to include the implementation of the `filterResults` function.
<docs-code header="Add the filterResults function implementation" path="adev/src/content/tutorials/first-app/steps/14-http/src/app/home/home.component.ts" visibleLines="[35,44]"/>
This function uses the `String` `filter` function to compare the value of the `text` parameter against the `housingLocation.city` property. You can update this function to match against any property or multiple properties for a fun exercise.
1. Save your code.
1. Refresh the browser and confirm that you can search the housing location data by city when you click the "Search" button after entering text.
<img alt="filtered search results based on user input" src="assets/images/tutorials/first-app/homes-app-lesson-13-step-3.png">
</docs-step>
</docs-workflow>
Summary: In this lesson, you updated your app to use template variables to interact with template values, and add search functionality using event binding and array functions.
For more information about the topics covered in this lesson, visit:
<docs-pill-row>
<docs-pill href="guide/templates" title="Template Variables"/>
<docs-pill href="guide/templates/event-listeners" title="Event Handling"/>
</docs-pill-row>
| {
"end_byte": 4598,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/13-search/README.md"
} |
angular/adev/src/content/tutorials/first-app/steps/13-search/src/index.html_0_427 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Homes</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
</head>
<body>
<app-root></app-root>
</body>
</html>
| {
"end_byte": 427,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/13-search/src/index.html"
} |
angular/adev/src/content/tutorials/first-app/steps/13-search/src/main.ts_0_536 | /*
* Protractor support is deprecated in Angular.
* Protractor is used in this example for compatibility with Angular documentation tools.
*/
import {bootstrapApplication, provideProtractorTestingSupport} from '@angular/platform-browser';
import {AppComponent} from './app/app.component';
import {provideRouter} from '@angular/router';
import routeConfig from './app/routes';
bootstrapApplication(AppComponent, {
providers: [provideProtractorTestingSupport(), provideRouter(routeConfig)],
}).catch((err) => console.error(err));
| {
"end_byte": 536,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/13-search/src/main.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/13-search/src/styles.css_0_443 | /* You can add global styles to this file, and also import other style files */
* {
margin: 0;
padding: 0;
}
body {
font-family: 'Be Vietnam Pro', sans-serif;
}
:root {
--primary-color: #605DC8;
--secondary-color: #8B89E6;
--accent-color: #e8e7fa;
--shadow-color: #E8E8E8;
}
button.primary {
padding: 10px;
border: solid 1px var(--primary-color);
background: var(--primary-color);
color: white;
border-radius: 8px;
}
| {
"end_byte": 443,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/13-search/src/styles.css"
} |
angular/adev/src/content/tutorials/first-app/steps/13-search/src/app/routes.ts_0_389 | import {Routes} from '@angular/router';
import {HomeComponent} from './home/home.component';
import {DetailsComponent} from './details/details.component';
const routeConfig: Routes = [
{
path: '',
component: HomeComponent,
title: 'Home page',
},
{
path: 'details/:id',
component: DetailsComponent,
title: 'Home details',
},
];
export default routeConfig;
| {
"end_byte": 389,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/13-search/src/app/routes.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/13-search/src/app/housinglocation.ts_0_180 | export interface HousingLocation {
id: number;
name: string;
city: string;
state: string;
photo: string;
availableUnits: number;
wifi: boolean;
laundry: boolean;
}
| {
"end_byte": 180,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/13-search/src/app/housinglocation.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/13-search/src/app/housing.service.ts_0_3182 | import {Injectable} from '@angular/core';
import {HousingLocation} from './housinglocation';
@Injectable({
providedIn: 'root',
})
export class HousingService {
readonly baseUrl = 'https://angular.dev/assets/images/tutorials/common';
protected housingLocationList: HousingLocation[] = [
{
id: 0,
name: 'Acme Fresh Start Housing',
city: 'Chicago',
state: 'IL',
photo: `${this.baseUrl}/bernard-hermant-CLKGGwIBTaY-unsplash.jpg`,
availableUnits: 4,
wifi: true,
laundry: true,
},
{
id: 1,
name: 'A113 Transitional Housing',
city: 'Santa Monica',
state: 'CA',
photo: `${this.baseUrl}/brandon-griggs-wR11KBaB86U-unsplash.jpg`,
availableUnits: 0,
wifi: false,
laundry: true,
},
{
id: 2,
name: 'Warm Beds Housing Support',
city: 'Juneau',
state: 'AK',
photo: `${this.baseUrl}/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: `${this.baseUrl}/ian-macdonald-W8z6aiwfi1E-unsplash.jpg`,
availableUnits: 1,
wifi: true,
laundry: false,
},
{
id: 4,
name: 'Happy Homes Group',
city: 'Gary',
state: 'IN',
photo: `${this.baseUrl}/krzysztof-hepner-978RAXoXnH4-unsplash.jpg`,
availableUnits: 1,
wifi: true,
laundry: false,
},
{
id: 5,
name: 'Hopeful Apartment Group',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/r-architecture-JvQ0Q5IkeMM-unsplash.jpg`,
availableUnits: 2,
wifi: true,
laundry: true,
},
{
id: 6,
name: 'Seriously Safe Towns',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/phil-hearing-IYfp2Ixe9nM-unsplash.jpg`,
availableUnits: 5,
wifi: true,
laundry: true,
},
{
id: 7,
name: 'Hopeful Housing Solutions',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/r-architecture-GGupkreKwxA-unsplash.jpg`,
availableUnits: 2,
wifi: true,
laundry: true,
},
{
id: 8,
name: 'Seriously Safe Towns',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/saru-robert-9rP3mxf8qWI-unsplash.jpg`,
availableUnits: 10,
wifi: false,
laundry: false,
},
{
id: 9,
name: 'Capital Safe Towns',
city: 'Portland',
state: 'OR',
photo: `${this.baseUrl}/webaliser-_TPTXZd9mOo-unsplash.jpg`,
availableUnits: 6,
wifi: true,
laundry: true,
},
];
getAllHousingLocations(): HousingLocation[] {
return this.housingLocationList;
}
getHousingLocationById(id: number): HousingLocation | undefined {
return this.housingLocationList.find((housingLocation) => housingLocation.id === id);
}
submitApplication(firstName: string, lastName: string, email: string) {
console.log(
`Homes application received: firstName: ${firstName}, lastName: ${lastName}, email: ${email}.`,
);
}
}
| {
"end_byte": 3182,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/13-search/src/app/housing.service.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/13-search/src/app/app.component.ts_0_671 | import {Component} from '@angular/core';
import {HomeComponent} from './home/home.component';
import {RouterLink, RouterOutlet} from '@angular/router';
@Component({
selector: 'app-root',
standalone: true,
imports: [HomeComponent, RouterLink, RouterOutlet],
template: `
<main>
<a [routerLink]="['/']">
<header class="brand-name">
<img class="brand-logo" src="/assets/logo.svg" alt="logo" aria-hidden="true" />
</header>
</a>
<section class="content">
<router-outlet></router-outlet>
</section>
</main>
`,
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'homes';
}
| {
"end_byte": 671,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/13-search/src/app/app.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/13-search/src/app/app.component.css_0_213 | :host {
--content-padding: 10px;
}
header {
display: block;
height: 60px;
padding: var(--content-padding);
box-shadow: 0px 5px 25px var(--shadow-color);
}
.content {
padding: var(--content-padding);
}
| {
"end_byte": 213,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/13-search/src/app/app.component.css"
} |
angular/adev/src/content/tutorials/first-app/steps/13-search/src/app/home/home.component.ts_0_1081 | import {Component, inject} from '@angular/core';
import {CommonModule} from '@angular/common';
import {HousingLocationComponent} from '../housing-location/housing-location.component';
import {HousingLocation} from '../housinglocation';
import {HousingService} from '../housing.service';
@Component({
selector: 'app-home',
standalone: true,
imports: [CommonModule, HousingLocationComponent],
template: `
<section>
<form>
<input type="text" placeholder="Filter by city" />
<button class="primary" type="button">Search</button>
</form>
</section>
<section class="results">
<app-housing-location
*ngFor="let housingLocation of housingLocationList"
[housingLocation]="housingLocation"
></app-housing-location>
</section>
`,
styleUrls: ['./home.component.css'],
})
export class HomeComponent {
housingLocationList: HousingLocation[] = [];
housingService: HousingService = inject(HousingService);
constructor() {
this.housingLocationList = this.housingService.getAllHousingLocations();
}
}
| {
"end_byte": 1081,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/13-search/src/app/home/home.component.ts"
} |
angular/adev/src/content/tutorials/first-app/steps/13-search/src/app/home/home.component.css_0_746 | .results {
display: grid;
column-gap: 14px;
row-gap: 14px;
grid-template-columns: repeat(auto-fill, minmax(400px, 400px));
margin-top: 50px;
justify-content: space-around;
}
input[type="text"] {
border: solid 1px var(--primary-color);
padding: 10px;
border-radius: 8px;
margin-right: 4px;
display: inline-block;
width: 30%;
}
button {
padding: 10px;
border: solid 1px var(--primary-color);
background: var(--primary-color);
color: white;
border-radius: 8px;
}
@media (min-width: 500px) and (max-width: 768px) {
.results {
grid-template-columns: repeat(2, 1fr);
}
input[type="text"] {
width: 70%;
}
}
@media (max-width: 499px) {
.results {
grid-template-columns: 1fr;
}
}
| {
"end_byte": 746,
"start_byte": 0,
"url": "https://github.com/angular/angular/blob/main/adev/src/content/tutorials/first-app/steps/13-search/src/app/home/home.component.css"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.