So You Want to Learn Angular? A Beginner's First Steps

By LearnWebCraft Team10 min readbeginner
AngularTypeScriptComponentsGetting StartedAngular CLI

Let’s be real for a second. Hearing the word "Angular" can sound... a little intimidating, right? It feels big, enterprise-y, and maybe a bit complicated. I remember when I first started, I pictured this giant, monolithic thing that would take me months just to wrap my head around.

But here’s the secret I wish someone had told me sooner—it’s not like that at all.

Honestly, Angular is more like a super-complete, high-end LEGO set. It gives you all the specialized pieces you need to build something incredible, right out of the box. And once you learn how a few of those core pieces snap together, everything starts to click. (Pun absolutely intended.)

So, if you're standing at the bottom of the "Angular mountain" looking up, just take a breath. We're going to climb it together, one simple step at a time. By the end of this, you won't just understand Angular; you'll have actually built your first app.

First Things First: What Are We Even Talking About?

So what is this thing, really? Angular is a full-blown framework for building web applications. It’s not just a library for one specific task; it’s a whole ecosystem designed to work together. Think of it this way:

  • It’s Component-Based: You build your UI out of reusable little chunks, just like LEGO bricks. A search bar, a user profile card, a navigation menu—those are all components.
  • It Loves TypeScript: This adds some amazing superpowers to JavaScript, like catching errors before you even run the code. It feels like a safety net, and trust me, it’s a game-changer.
  • The CLI is Your Best Friend: There’s a command-line tool that does all the heavy lifting for you—creating projects, components, services... you name it. It's amazing.
  • Everything's Included: Routing, making API calls, handling forms... it's all part of the package. You don’t have to go hunting for a dozen other libraries just to get a project off the ground.

Getting Your Workshop Ready

Before we can start building, we need to make sure our tools are in order. It's a short list, I promise.

You’ll need:

  • Node.js: This is the engine that lets JavaScript run outside of a web browser. Make sure you have version 18 or newer.
  • npm: This is the Node Package Manager. It comes bundled with Node.js, so if you have one, you have the other. Easy peasy.
  • A Code Editor: I’m a big fan of VS Code, and a lot of the Angular world is too. It just plays really, really well with TypeScript.

Got all that? Awesome. Let's install the main event.

Meet the Angular CLI: Your Magic Wand

The Angular Command Line Interface (CLI) is where the magic begins. Seriously, this thing is your personal assistant for everything Angular. Let’s get it installed on your machine globally so you can use it for any project, anytime.

Open your terminal and run this command:

npm install -g @angular/cli

Once it’s done its thing, you can double-check that it installed correctly by typing ng version. If you see a bunch of version numbers pop up, you're officially in business. Welcome to the club!

Let's Build Something! Your First App

Okay, deep breath. It's time to create our very first Angular project. And believe it or not, it’s just one command. That's it.

# This 'ng new' command creates a new workspace and an initial app
ng new my-first-app

# Now, let's move into our new project's home
cd my-first-app

# And fire it up!
ng serve --open

The CLI is going to ask you a couple of questions. Don't sweat it, they're pretty straightforward.

  • "Would you like to add Angular routing?" → Go ahead and say Yes. You'll almost always want this. It's what lets you create different "pages" or views in your app.
  • "Which stylesheet format would you like to use?" → Just pick CSS for now. It’s the simplest to start with, no need to overcomplicate things yet.

After a moment or two, your browser should pop open to http://localhost:4200, and you'll be greeted by a default Angular welcome page.

Look at that! You’re an Angular developer. Feels pretty good, right?

What Did We Just Make? A Quick Tour

Okay, I know. The CLI just created a bunch of files. It can look like a lot at first glance, but you only need to care about a few of them for now. Let’s peek inside the src/app/ folder, which is where we'll be spending most of our time:

  • app.component.ts: This is the logic for our main component. Think of this as the component's brain.
  • app.component.html: This is the structure or the template. You can think of it as the skeleton.
  • app.component.css: This is where the style lives. The clothes, if you will.
  • app.routes.ts: This is the roadmap for our application's pages.

This little trio—TS, HTML, and CSS—is the heart of every single component you'll ever build in Angular.

Components: The LEGO Bricks of Angular

Everything you see on the screen in an Angular app is part of a component. So let’s break down that main app.component.ts file to see what's actually going on under the hood.

// src/app/app.component.ts
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [RouterOutlet],
  templateUrl: './app.component.html',
  styleUrl: './app.component.css'
})
export class AppComponent {
  title = 'my-first-app'; // This is a property we can use
}

This might look a little strange at first, but let's walk through it. It's simpler than it looks.

  • The @Component({...}) part is called a decorator. It’s just a way of telling Angular, "Hey, this class isn't just a regular class—it's a component with some special configuration."
  • selector: This is the custom HTML tag for this component. If you look, you'll see <app-root> in the main index.html file. That's this component!
  • templateUrl: This just points to our component's HTML file.
  • styleUrl: And this one points to our CSS file.
  • export class AppComponent: This is just a standard JavaScript class where all our component's logic will live. See that title property? We can use that directly in our HTML.

Let's see how that works. Open up app.component.html, delete everything that's in there, and replace it with this:

<!-- src/app/app.component.html -->
<div style="text-align:center">
  <h1>Welcome to {{ title }}!</h1>
  <p>This is my very first Angular app. It's pretty cool.</p>
</div>

<router-outlet></router-outlet>

As soon as you save the file, your browser should automatically refresh. See how {{ title }} was magically replaced with 'my-first-app'? That’s called interpolation, and it's our first taste of data binding. For many people, this is the moment things really start to click.

Let's Make Our Own Component

The app-root component is a great start, but real apps are made of many components working together. So let's create our own. We’ll make a simple user profile card. Back in your terminal (make sure you're still in the my-first-app directory), run this CLI command:

ng generate component user-profile
# Or the cool shorthand version:
# ng g c user-profile

And just like that, the CLI created a new user-profile folder with all the files we need. How awesome is that? No tedious manual setup.

Now, let's add some life to it. Open up the new user-profile.component.ts and user-profile.component.html.

// src/app/user-profile/user-profile.component.ts
import { Component } from '@angular/core';

@Component({
  selector: 'app-user-profile',
  standalone: true,
  imports: [],
  templateUrl: './user-profile.component.html',
  styleUrl: './user-profile.component.css'
})
export class UserProfileComponent {
  // Let's add some data for our user
  userName = 'Jane Doe';
  userHandle = '@janedoe';
  userAvatar = 'https://i.pravatar.cc/150'; // A handy placeholder image service
}

And now for the HTML to display that data.

<!-- src/app/user-profile/user-profile.component.html -->
<div class="profile-card">
  <img [src]="userAvatar" [alt]="userName">
  <h2>{{ userName }}</h2>
  <p>{{ userHandle }}</p>
  <button (click)="sayHello()">Say Hello</button>
</div>

Whoa, hang on. What are those [src] and (click) things with the weird brackets?

  • Property Binding [ ]: The square brackets let you bind a component property directly to an HTML element’s property. We're essentially telling the <img> tag, "Hey, your src attribute should always be equal to whatever is in my userAvatar variable."
  • Event Binding ( ): The parentheses let you listen for DOM events, like clicks, mouse movements, or key presses. Here, we're telling the <button>, "When you get clicked, I want you to run my sayHello() method."

Of course, for that to work, we actually need to create that sayHello method. Let's hop back to user-profile.component.ts:

// ... inside the UserProfileComponent class
export class UserProfileComponent {
  userName = 'Jane Doe';
  userHandle = '@janedoe';
  userAvatar = 'https://i.pravatar.cc/150';

  sayHello() {
    alert(`Hello from ${this.userName}!`);
  }
}

Okay, our component is ready to go! But... if you look at your browser, nothing has changed. Why is that? Well, we've built our new LEGO brick, but we haven't actually snapped it into our main structure yet.

Let’s go to app.component.ts and tell it about our new component by importing it.

// src/app/app.component.ts
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { UserProfileComponent } from './user-profile/user-profile.component'; // <-- Import it here

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [RouterOutlet, UserProfileComponent], // <-- And add it to the imports array
  templateUrl: './app.component.html',
  styleUrl: './app.component.css'
})
export class AppComponent {
  title = 'my-first-app';
}

Finally, we can use its selector (app-user-profile) in our main HTML file, just like any other HTML tag.

<!-- src/app/app.component.html -->
<div style="text-align:center">
  <h1>Welcome to {{ title }}!</h1>
</div>

<!-- Let's add our new component right here! -->
<app-user-profile></app-user-profile>

<router-outlet></router-outlet>

Save everything. Now check your browser. Boom. There it is. Your very own, custom-built component, live on the page.

So, What's Next on This Adventure?

You just did it. You went from zero to a running Angular app with a custom component. You’ve learned the absolute core concepts: using the CLI, what components are, interpolation, and data binding. That’s HUGE. Seriously, give yourself a pat on the back.

This is the foundation for everything else in Angular. From here, you can start to explore:

  • Directives like *ngIf and *ngFor: These are your tools for showing/hiding elements and looping over lists of data. They feel like superpowers for your HTML.
  • Services & Dependency Injection: This is the "proper" way to handle your app's logic and data in a clean, organized way.
  • Routing: Building a real application with multiple pages or views.
  • Forms: Capturing user input, which is, you know, kind of important for most apps.

My advice? Don't try to learn it all at once. Play with what you’ve built today. Change the user data. Add another button. Try to break it, then fix it, and see what happens.

You've already taken the first, and hardest, step. The rest is just snapping more LEGOs together. You got this.

Related Articles