-
Book Overview & Buying
-
Table Of Contents
Angular Projects - Fourth Edition
By :
The latest version of VS Code includes a built-in integration of GitHub Copilot. We will learn how to use Copilot as an AI pair programmer and develop Angular applications in the following ways:
In the following sections, we will explore both concepts as we continue to develop our Angular application.
AI agents use instructions to define a working context and operate within specific boundaries. Instructions define the role and capabilities of the agent in the current context. The Angular CLI created an instructions file for Copilot while creating the application:
my‑app folder and select it. VS Code will load the associated Angular CLI project..github folder and select the copilot‑instructions.md file. The Markdown file contains instructions that help Copilot understand Angular.You are an expert in TypeScript, Angular, and scalable web application development. You write functional, maintainable, performant, and accessible code following Angular and TypeScript best practices.
## TypeScript Best Practices
- Use strict type checking
- Prefer type inference when the type is obvious
- Avoid the `any` type; use `unknown` when type is uncertain
State Management heading:
- Define signal properties as `readonly`
The preceding instruction will guide Copilot to declare signals with the readonly keyword.
The Markdown format of the instructions file makes it accessible to all developers. You now understand how easy it is to extend it and share it with other members of your development team. In the following section, we will learn how Copilot uses instructions to interact with our Angular application.
GitHub Copilot is pre-installed and enabled by default in the latest version of VS Code. It opens automatically in the CHAT side panel when we load an Angular application.
If the panel is not opened, you can use the Toggle Chat button in the top bar near the search input.
The CHAT panel features a welcome screen and an input box that allows us to interact with Copilot using prompts:

Figure 1.1 – GitHub Copilot
First, we will use Copilot to refactor the existing code base of the Angular application.
AI agents are not deterministic, which means their responses may vary in every run. The steps that you will follow in this section may result in a different output than the one described in the section.
We will create a new property in the App component class for chapter titles:
Create a signal in the App component for storing the chapter title with the following value: Chapter 1: Angular AI Kick-Starter.

Figure 1.2 – Sign in to use GitHub Copilot
After the sign-in process is complete, Copilot creates a chapterTitle property in the App component class.
Enter the following prompt:
Update the title in the template according to the chapter title.
Copilot changes the line in the template file that displayed the title property to the following:
<h1>{{ chapterTitle() }}</h1>
ng serve command and navigate to localhost:4200:

Figure 1.3 – Application output
You have learned how to refactor an existing Angular application without needing to interact with the code. Copilot did all the required work using prompts.
We can use Copilot for more complicated tasks, such as creating new components and services:
Create a component responsible for displaying the chapter title and use it in the App component.
The previous prompt will create a new component based on the Components best practices from the instructions file.
chapterTitle property using an input signal. Examine the browser to verify that the application output is still the same.You now understand how much faster it is to develop Angular applications with Copilot. We learned how to create a component without using the Angular CLI. You can use the same process to generate different parts of an Angular application, such as services and directives.