<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Suryansh Chauhan</title>
    <description>The latest articles on Forem by Suryansh Chauhan (@suryansh_chauhan_1da74cb6).</description>
    <link>https://forem.com/suryansh_chauhan_1da74cb6</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3624948%2F1c0b52a6-33d6-4232-a7d3-39d05c306385.png</url>
      <title>Forem: Suryansh Chauhan</title>
      <link>https://forem.com/suryansh_chauhan_1da74cb6</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/suryansh_chauhan_1da74cb6"/>
    <language>en</language>
    <item>
      <title>🚀 Angular Cheat Sheet 2025: The Beginner’s Guide to Modern Angular</title>
      <dc:creator>Suryansh Chauhan</dc:creator>
      <pubDate>Sat, 22 Nov 2025 23:07:36 +0000</pubDate>
      <link>https://forem.com/suryansh_chauhan_1da74cb6/angular-cheat-sheet-2025-the-beginners-guide-to-modern-angular-4f7p</link>
      <guid>https://forem.com/suryansh_chauhan_1da74cb6/angular-cheat-sheet-2025-the-beginners-guide-to-modern-angular-4f7p</guid>
      <description>&lt;p&gt;Angular has changed a lot recently. If you learned it years ago (or never learned it at all), the new "Modern Angular" is simpler, faster, and way more fun. 🎉&lt;/p&gt;

&lt;p&gt;Gone are the days of complex modules and slow performance. Welcome to the era of Signals and Standalone Components.&lt;/p&gt;

&lt;p&gt;Here is your quick cheat sheet to master the basics in 2025! 👇&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;🏗️ The Component (The Building Block)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Think of a Component as a Lego brick. It controls one part of your screen. In 2025, components are "Standalone" by default—you don't need to register them in a heavy Module anymore.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Component } from '@angular/core';

@Component({
  selector: 'app-hello',
  standalone: true, // 👈 The Magic Word
  template: `
    &amp;lt;h1&amp;gt;Hello, {{ name }}! 👋&amp;lt;/h1&amp;gt;
  `,
})
export class HelloComponent {
  name = 'Developer';
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;📡 Signals (Managing Data)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is the biggest change! 🚨 In the past, we used simple variables. Now, we use Signals. Think of a Signal as a special box that holds a value and shouts to the app whenever that value changes.&lt;/p&gt;

&lt;p&gt;Creating a Signal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// 1. Import it
import { signal } from '@angular/core';

// 2. Create it
count = signal(0); 

// 3. Change it
increase() {
  // .set() replaces the value
  this.count.set(5); 

  // .update() uses the old value to make a new one
  this.count.update(value =&amp;gt; value + 1);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reading a Signal (in HTML)&lt;/p&gt;

&lt;p&gt;Crucial Rule: You must call a signal like a function () to read it!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p&amp;gt;The count is: {{ count() }}&amp;lt;/p&amp;gt;

&amp;lt;p&amp;gt;The count is: {{ count }}&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;🚦 Logic in HTML (@if &amp;amp; &lt;a class="mentioned-user" href="https://dev.to/for"&gt;@for&lt;/a&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Angular used to have confusing syntax like *ngIf. Now, it looks just like JavaScript! It is cleaner and easier to read.&lt;/p&gt;

&lt;p&gt;Conditional (@if)&lt;/p&gt;

&lt;p&gt;Show or hide things easily. 🫣&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@if (isLoggedIn()) {
  &amp;lt;button&amp;gt;Logout 🚪&amp;lt;/button&amp;gt;
} @else {
  &amp;lt;button&amp;gt;Login 🔑&amp;lt;/button&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Looping (&lt;a class="mentioned-user" href="https://dev.to/for"&gt;@for&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Display a list of items. 📝 Note: You must use track to tell Angular how to identify items (usually by ID).\&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ul&amp;gt;
  @for (user of users(); track user.id) {
    &amp;lt;li&amp;gt;{{ user.name }} 👤&amp;lt;/li&amp;gt;
  } @empty {
    &amp;lt;li&amp;gt;No users found! 🤷‍♂️&amp;lt;/li&amp;gt;
  }
&amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;🔌 Inputs (Passing Data Down)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How do you pass data from a Parent component to a Child component? Use the new input() signal!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// In the Child Component
import { input } from '@angular/core';

export class UserCardComponent {
  // This input is required! The app will crash if you forget it.
  name = input.required&amp;lt;string&amp;gt;(); 

  // This one has a default value
  role = input('Guest'); 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;⚡ Super Speed with &lt;a class="mentioned-user" href="https://dev.to/defer"&gt;@defer&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is a superpower for performance. You can tell Angular: "Don't load this heavy part of the page until the user actually needs it."&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@defer (on viewport) {
  &amp;lt;heavy-chart-component /&amp;gt; 📊
} @placeholder {
  &amp;lt;p&amp;gt;Scroll down to see the chart... ⬇️&amp;lt;/p&amp;gt;
} @loading {
  &amp;lt;spinner /&amp;gt; ⏳
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;💉 Getting Tools (Injection)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Stop putting everything in the constructor. The modern way to get services (like HTTP or Router) is using inject().&lt;/p&gt;

&lt;p&gt;import { inject } from '@angular/core';&lt;br&gt;
import { HttpClient } from '@angular/common/http';&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export class DataService {
  // Cleaner and less typing! ✨
  private http = inject(HttpClient);

  getData() {
    return this.http.get('/api/data');
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;📝 Summary&lt;/p&gt;

&lt;p&gt;Modern Angular in 2025 is all about:&lt;/p&gt;

&lt;p&gt;Standalone Components (No more Modules)&lt;/p&gt;

&lt;p&gt;Signals (Better state management)&lt;/p&gt;

&lt;p&gt;@if / &lt;a class="mentioned-user" href="https://dev.to/for"&gt;@for&lt;/a&gt; (Better HTML syntax)&lt;/p&gt;

&lt;p&gt;inject() (Better dependency injection)&lt;/p&gt;

&lt;p&gt;Ready to build something cool? Let me know in the comments! 👇&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>angular</category>
      <category>cheatsheet</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
