Skip to main content

Getting Started with Angular 18 (2025): A Complete Beginner’s Guide to Directives, Two-Way Data Binding, and How It Compares with React and Vue

Introduction

If you’re stepping into modern front-end development in 2025, you’ve probably heard of Angular, React, and Vue — the three giants powering the web today. Angular, built and maintained by Google, remains a top choice for scalable enterprise applications and robust single-page apps (SPAs).

This tutorial is your step-by-step beginner’s guide to getting started with the latest version — Angular 18 (as of 2025). We’ll cover how to set up your first project, create custom directives, understand two-way data binding, and compare Angular with ReactJS and VueJS.


🧭 What Is Angular?

Angular is a TypeScript-based front-end framework designed for building dynamic, modular, and reactive web applications. Unlike React (a library) or Vue (a progressive framework), Angular provides a complete solution — including routing, forms, HTTP communication, and dependency injection — right out of the box.

Some standout Angular features include:

  • 🧩 Modular architecture using components and modules

  • 🔁 Two-way data binding

  • Dependency Injection

  • 📦 Built-in tools for routing and HTTP

  • 🧠 Strong TypeScript and Reactive Programming support


⚙️ Setting Up Angular 18

1. Install Node.js and Angular CLI

Before anything else, make sure you have Node.js (v18 or later) installed.
You can check your version by running:

node -v npm -v

Then, install the Angular CLI globally:

npm install -g @angular/cli

Verify the installation:

ng version

2. Create a New Angular Project

Now, create a new project:

ng new my-angular-app

During setup, you’ll be asked a few questions (like adding routing and choosing CSS/SCSS). Once done, navigate to your new folder:

cd my-angular-app

Start the development server:

ng serve

Then visit http://localhost:4200 in your browser — you should see the default Angular welcome page 🎉


🧱 Understanding Angular Directives

Directives are one of Angular’s most powerful features. They let you extend HTML’s capabilities by adding new behaviors to elements in the DOM.

Angular comes with three types of directives:

  1. Component Directives — These are directives with templates (basically components).

  2. Structural Directives — Modify the DOM structure (like *ngIf, *ngFor).

  3. Attribute Directives — Change the appearance or behavior of an existing element (like ngStyle, ngClass).


Creating a Custom Directive (Step-by-Step)

Let’s build a simple custom directive that highlights text when the user hovers over it.

  1. Generate the directive using Angular CLI:

    ng generate directive highlight
  2. Open highlight.directive.ts. It should look like this:

    import { Directive, ElementRef, HostListener, Input } from '@angular/core'; @Directive({ selector: '[appHighlight]' }) export class HighlightDirective { @Input() appHighlight = ''; constructor(private el: ElementRef) {} @HostListener('mouseenter') onMouseEnter() { this.highlight(this.appHighlight || 'yellow'); } @HostListener('mouseleave') onMouseLeave() { this.highlight(''); } private highlight(color: string) { this.el.nativeElement.style.backgroundColor = color; } }
  3. Use it in a component template:

    <p appHighlight="lightblue">Hover over me to see the highlight effect!</p>

You’ve just created your first custom directive — one of the building blocks of Angular development!


🔁 Two-Way Data Binding in Angular

Angular’s two-way data binding keeps your component class and template in sync automatically. When a user updates input fields, the component’s data updates instantly — and vice versa.

You use Angular’s special syntax called [(ngModel)] (known as the banana-in-a-box syntax 🍌📦).

Example:

In your component file (app.component.ts):

export class AppComponent { username: string = 'Bhuman'; }

In your template (app.component.html):

<input [(ngModel)]="username" placeholder="Enter your name"> <p>Hello, {{ username }}!</p>

Note: For ngModel to work, you need to import FormsModule in your app.module.ts:

import { FormsModule } from '@angular/forms'; @NgModule({ imports: [BrowserModule, FormsModule], ... }) export class AppModule {}

Now, as you type in the input field, the text in the paragraph updates in real-time — that’s two-way binding in action!


⚖️ Angular vs React vs Vue (2025 Comparison)

FeatureAngular 18React 19Vue 4
TypeFull-fledged FrameworkUI LibraryProgressive Framework
LanguageTypeScriptJavaScript / TypeScriptJavaScript / TypeScript
Learning CurveSteep (more concepts)ModerateEasy
Data BindingTwo-way bindingOne-way (with manual handlers)Two-way (v-model)
DOM HandlingReal DOMVirtual DOMVirtual DOM
State ManagementBuilt-in via servicesRedux / Context APIVuex / Pinia
PerformanceExcellent for large-scale appsVery fast for UI-heavy appsFast and lightweight
Use CaseEnterprise appsDynamic UIsSmall to mid-scale apps

In short:

  • Use Angular if you want a full solution with strong TypeScript integration.

  • Use React for flexible, component-based UI development.

  • Use Vue if you want simplicity with good scalability.


🧠 Final Thoughts

Angular remains one of the most complete and enterprise-ready frameworks in 2025. Its directives, dependency injection, and two-way data binding make it a developer favorite for building large, maintainable apps.

If you’re just starting out:

  • Learn components, directives, and data binding.

  • Practice using the Angular CLI.

  • Gradually explore services, routing, and RxJS for reactive programming.


Recommended Next Steps

Comments

Popular posts from this blog

Upload to AWS S3 from Java API

In this post, you will see code samples for how to upload a file to AWS S3 bucket from a Java Spring Boot app. The code you will see here is from one of my open-source repositories on Github, called document-sharing. Problem Let’s say you are building a document sharing app where you allow your users to upload the file to a public cloud solution. Now, let’s say you are building the API for your app with Spring Boot and you are using AWS S3 as your public cloud solution. How would you do that? This blog post contains the code that can help you achieve that. Read more below,  Upload to AWS S3 bucket from Java Spring Boot app - My Day To-Do (mydaytodo.com)

Html5 based widget for an iOS app: Today extension powered by the Ionic framework

At some point the thought of adding a Widget to my iOS app came to mind which was followed by starting work on adding a widget for my app, My Day Todos . Obviously the first step was to learn how to add a Widget to an iOS app and in that learning process I discovered many things about widgets in iOS first of which was a widget in iOS is a an app extension i.e a  Today Extension . While I am still haven't finished working on the widget for my iOS app, I thought I would take some time out and share what I have learned. In this post, I will share a few important tips and provide an example of how to add a Widget to an iOS app and have the widget UI powered by Html5 via  Ionic framework . I added some code to my Github repo, Html5StarterAppWithSwift in order to show how this can be achieved. There are already too many tutorials out on the Web on how to add a Today extension to an iOS app so I won't be including that here. Instead I will focus on sharing some of the useful tip...

Build a Full-Stack Image Upload App with Node.js, Express, React, and Vite (Beginner Tutorial)

 If you’re new to full-stack web development and want a hands-on project to practice React frontend integration with a Node.js + Express backend , this tutorial is for you. In this guide, we’ll walk through a simple but powerful app that lets users upload images, store them on the server, and display them back in the browser. This project is based on my GitHub repo: node-express-react-simple-fileupload . It’s designed to be beginner-friendly, SEO-optimized, and a great starting point for anyone learning JavaScript full-stack development . 🛠️ Technologies Used Here’s the tech stack powering this project: Node.js – JavaScript runtime for the backend. Express.js – Lightweight web framework for building REST APIs. Multer – Middleware for handling file uploads. CORS – Enables cross-origin requests between frontend and backend. React.js – Frontend library for building user interfaces. Vite – Fast development server and build tool for React. Fetch API – For making HTTP requests ...