Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. TypeScript Mastery

Lesson 32 of 56 · Typescript

Angular Basics – TypeScript Foundations

Duration: 30 minutes

Angular CLI

npm install -g @angular/cli
ng new ng‑app --strict

--strict enables the strict type‑checking options.

Component Class

import { Component } from '@angular/core';

@Component({ selector: 'app-hello', template: `<h1>Hello {{name}}</h1>` })
export class HelloComponent {
  name: string = 'Angular';
}

Input & Output

import { Input, Output, EventEmitter } from '@angular/core';

@Component({ selector: 'counter', template: `
  <button (click)="decrement()">-</button>
  {{count}}
  <button (click)="increment()">+</button>
` })
export class CounterComponent {
  @Input() count = 0;
  @Output() countChange = new EventEmitter<number>();
  increment() { this.count++; this.countChange.emit(this.count); }
  decrement() { this.count--; this.countChange.emit(this.count); }
}

Service with Dependency Injection

import { Injectable } from '@angular/core';

@Injectable({ providedIn: 'root' })
export class DataService {
  fetch<T>(url: string): Promise<T> {
    return fetch(url).then(r => r.json() as Promise<T>);
  }
}

Info

Angular’s strict mode adds type‑safe templates, catching many errors at compile time.

Previous: Redux Toolkit + TypeScriptNext: RxJS Typing