DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk3 min

How to Generate and Render Angular’s Home Component

Use Angular CLI to generate Home, add it to the root template, and display the lesson’s initial city filter controls.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run ng generate component home from your Angular project directory to create the component. To make it appear, import it into the root component and place its selector in the root template; generating the files alone does not add it to the page.

What an Angular component contains

An Angular component is a TypeScript class with a template and a selector, described by @Component metadata. The template defines the component’s HTML, and the selector is the element name a parent template uses to render it. CSS styles are optional and can be inline or in a separate file.

As an Amazon Associate I earn from qualifying purchases.

This walkthrough follows Angular’s official first-app lesson, whose starter project uses src/app/app.ts for the root component and src/app/home/home.ts for the new component. Other projects may organize files or name root components differently, so follow your workspace’s conventions if they differ. See Angular’s Create Home component lesson and components guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Generate the Home component

  1. Open a terminal in the Angular project directory—the directory containing the project configuration.

  2. Run ng generate component home. The CLI generates the component files according to the project’s configuration. The current component command reference documents the command as ng generate component [name] [options].

  3. Start the development server with ng serve and confirm that the project builds. Creating the component does not, by itself, make its content appear in the app.

Import and render Home in the root component

In the tutorial’s starter project, open src/app/app.ts. Import Home from ./home/home, add it to the root component’s imports array, and add its selector to the root template:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { Home } from './home/home';

// In the root component's @Component metadata:
imports: [Home],
template: ``,

If the component’s generated metadata or your project structure differs, use the actual export and file path in your workspace. The key is that the parent component must know about Home and include its selector in the parent template. In Angular’s lesson, that selector is app-home, so <app-home /> is what renders the component in the root layout.

Save the file and check the app in the browser. The root content should now include the Home component.

Add the lesson’s initial filter controls

To match the next step in the first-app lesson, edit src/app/home/home.ts and add the example form markup to the component template. Then edit src/app/home/home.css to apply the lesson’s styles. Its visible controls are an input with the placeholder Filter by city and a Search button.

Save the files and check the running app again; the input and button should be visible. At this stage, they are only part of the layout: the lesson does not implement filtering or make the Search button functional. The controls need additional application logic before they can search or filter data.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check standalone and NgModule conventions

Angular’s current CLI reference lists standalone component generation as the default. However, that default depends on Angular version: the components guide says standalone defaulted to false before Angular 19.0. Older projects or projects built around NgModules may therefore require a different integration pattern than the standalone root-component example above.

Check the Angular version and how neighboring components are declared and imported before changing the generated setup. The CLI generate overview explains that generation uses schematics; the component command reference describes options that affect the generated files and configuration. Keep the new component consistent with the project rather than assuming that every Angular workspace uses the same defaults.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.