Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Unix & Linux ServerSecurity: Denial of Service in Memcached (Ubuntu)(21.09.2026 um 19:21 Uhr)
Sichere ProgrammierungGrok 4.7 is now available in GitHub Copilot(21.09.2026 um 16:54 Uhr)
Sichere ProgrammierungCleaning Up Unused Indexes Without Breaking Performance(21.09.2026 um 18:55 Uhr)
Sichere Programmierung52 security tools, one judgment layer, 35 seconds(21.09.2026 um 19:08 Uhr)
Sichere ProgrammierungSpring Boot Learning by doing(21.09.2026 um 19:12 Uhr)
Sichere ProgrammierungInternet 101 - Chapter 1 : Making LAN(21.09.2026 um 19:14 Uhr)
Unix & Linux ServerSecurity: Denial of Service in Memcached (Ubuntu)(21.09.2026 um 19:21 Uhr)
Sichere ProgrammierungGrok 4.7 is now available in GitHub Copilot(21.09.2026 um 16:54 Uhr)
Sichere ProgrammierungCleaning Up Unused Indexes Without Breaking Performance(21.09.2026 um 18:55 Uhr)
Sichere Programmierung52 security tools, one judgment layer, 35 seconds(21.09.2026 um 19:08 Uhr)
Sichere ProgrammierungSpring Boot Learning by doing(21.09.2026 um 19:12 Uhr)
Sichere ProgrammierungInternet 101 - Chapter 1 : Making LAN(21.09.2026 um 19:14 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Angular Modules

1. What is an NgModule An NgModule groups related components, directives, and pipes together. It was the primary way to structure Angular apps before standalone components arrived in Angular 14. NgModules are not deprecated — they are s…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!




1. What is an NgModule



An NgModule groups related components, directives, and pipes together. It was the primary way to structure Angular apps before standalone components arrived in Angular 14.



NgModules are not deprecated — they are still fully supported in Angular 21. Only platformBrowserDynamic (the old bootstrap function) was deprecated. The recommended path for new projects is standalone components, but NgModules remain valid for existing codebases.









2. NgModule Anatomy



The @NgModule decorator accepts five main properties:
































Property Purpose
declarations Non-standalone components, directives, and pipes owned by this module
imports Other NgModules or standalone components/pipes this module needs
exports What this module exposes to other modules that import it
providers Services to register (prefer providedIn: 'root' on the service itself)
bootstrap The root component Angular renders on startup — root module only





@NgModule({
declarations: [App],
bootstrap: [App],
imports: [BrowserModule, CommonModule, Tasks, NewTask, Task, User, Header, RouterOutlet],
})
export class AppModule {}












3. declarations vs imports



This is the most common source of confusion when mixing modules with standalone components.





  • declarations — only for non-standalone components (standalone: false). They are private to this module unless explicitly exported.


  • imports — for other NgModules and for standalone components, directives, and pipes (the default since Angular 17).



Putting a standalone component in declarations causes a compile error. Putting a non-standalone component in imports also causes an error.




// non-standalone component — belongs in declarations
@Component({
standalone: false,
selector: 'app-root',
templateUrl: './app.html',
styleUrl: './app.css',
})
export class App {}









// standalone component (Angular 17+ default) — belongs in imports, not declarations
@Component({
selector: 'app-header',
templateUrl: './header.html',
})
export class Header {}









@NgModule({
declarations: [App], // non-standalone
imports: [BrowserModule, Header, RouterOutlet], // standalone components go here
bootstrap: [App],
})
export class AppModule {}






A non-standalone component also cannot have an imports array in @Component — it delegates all imports to its module.









4. BrowserModule vs CommonModule




















Module Use when
BrowserModule Root module only — sets up the browser platform, includes CommonModule internally
CommonModule Feature modules — provides NgIf, NgFor, NgClass, pipes, etc.


Never import BrowserModule in a feature module — import CommonModule instead. Importing BrowserModule twice throws a runtime error.









5. Bootstrapping with NgModule



Use platformBrowser().bootstrapModule() from @angular/platform-browser. The older platformBrowserDynamic from @angular/platform-browser-dynamic was deprecated in Angular 21.




// main.ts
import { platformBrowser } from '@angular/platform-browser';
import { AppModule } from './app/app.module';

platformBrowser().bootstrapModule(AppModule)
.catch((err: unknown) => console.error(err));












6. Feature Modules



Feature modules group a slice of the app (e.g. tasks, users) to keep AppModule small. They export only what the rest of the app needs.




// tasks/tasks.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TasksComponent } from './tasks.component';

@NgModule({
declarations: [TasksComponent],
imports: [CommonModule],
exports: [TasksComponent],
})
export class TasksModule {}









// app.module.ts
@NgModule({
declarations: [App],
imports: [BrowserModule, TasksModule],
bootstrap: [App],
})
export class AppModule {}












7. Lazy-Loaded Feature Modules



Lazy loading defers loading a module's bundle until the user navigates to its route. Configure it with loadChildren in the router:




// app.routes.ts
export const routes: Routes = [
{
path: 'tasks',
loadChildren: () =>
import('./tasks/tasks.module').then((m) => m.TasksModule),
},
];









// tasks/tasks.module.ts — use forChild, not forRoot
@NgModule({
declarations: [TasksComponent],
imports: [
CommonModule,
RouterModule.forChild([{ path: '', component: TasksComponent }]),
],
})
export class TasksModule {}






The root module uses RouterModule.forRoot(routes). Feature modules use RouterModule.forChild(routes).









8. NgModule vs Standalone






































NgModule Standalone
Grouping Explicit module files No module needed
Sharing Export from module, import the module Import the component directly
Lazy loading loadChildren loadComponent
Recommended for new projects No Yes
Deprecated No


NgModules are still valid and fully supported. Understanding them is essential for working with existing Angular codebases.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Angular Modules

Thematisch verwandte Begriffe: Angular, Modules · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-82412 | ntopng is a web-based network traffic monitoring application. Prior to 6…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick