100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Angular Cheat Sheet

Angular Cheat Sheet

A practical reference covering Angular CLI commands, standalone components, core decorators, and dependency injection for building single-page applications.

3 PagesIntermediateMar 15, 2026

Angular CLI Commands

Common commands for scaffolding and running an Angular project.

bash
ng new my-app                        # scaffold a new projectng serve                             # dev server with live reloadng generate component my-component   # shorthand: ng g c my-componentng generate service my-service       # shorthand: ng g s my-serviceng build --configuration production  # production buildng test                              # run unit testsng add @angular/material             # add and configure a library

Standalone Component

A modern standalone component with template directives.

typescript
import { Component } from '@angular/core';@Component({  selector: 'app-hello',  standalone: true,  template: `    <h1>{{ title }}</h1>    <ul>      <li *ngFor='let item of items'>{{ item.name }}</li>    </ul>    <input [(ngModel)]='search' />    <button (click)='increment()'>+1</button>  `,})export class HelloComponent {  title = 'Hello Angular';  items = [{ name: 'One' }, { name: 'Two' }];  search = '';  count = 0;  increment() {    this.count++;  }}

Core Decorators

The decorators you will use in almost every Angular app.

  • @Component- marks a class as an Angular component and attaches a template/selector
  • @Injectable- marks a class as available for dependency injection, typically a service
  • @Input- declares a property that can receive data bound from a parent component
  • @Output- declares an EventEmitter a component uses to emit events to its parent
  • @NgModule- (legacy) groups components, directives and providers into a module; optional with standalone APIs
  • @HostListener- binds a class method to a DOM event fired on the component's host element

Services & Dependency Injection

Defining an injectable service and consuming it with inject().

typescript
import { Injectable, inject } from '@angular/core';import { HttpClient } from '@angular/common/http';@Injectable({ providedIn: 'root' })export class DataService {  private http = inject(HttpClient);  getUsers() {    return this.http.get('/api/users');  }}// consuming the service in a componentexport class UsersComponent {  private dataService = inject(DataService);}
Pro Tip

Standalone components have been the default since Angular 17 -- prefer them over NgModule-based components to cut boilerplate, and use the inject() function instead of constructor injection inside functional guards and resolvers, where there is no constructor to inject into.

Was this cheat sheet helpful?

Explore Topics

#Angular#AngularCheatSheet#WebDevelopment#Intermediate#AngularCLICommands#StandaloneComponent#CoreDecorators#ServicesDependencyInjection#CommandLine#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech

Professional Web Designing Services

  • Responsive Websites
  • E-commerce Solutions
  • SEO Friendly Design
  • Fast & Secure
  • Support & Maintenance
Get a Free Quote

Share this Cheat Sheet