Introduction
The Angular Core API provides the fundamental building blocks for creating Angular applications. This module contains decorators, functions, and interfaces that enable component creation, dependency injection, lifecycle management, and reactive data handling.Key Concepts
Decorators
Angular uses TypeScript decorators to add metadata to classes and class members:- @Component - Defines a component with template and styles
- @Directive - Creates reusable behaviors for DOM elements
- @Injectable - Marks a class as available for dependency injection
- @Input - Declares input properties for data binding
- @Output - Declares output properties for event emission
Components and Directives
Components are the basic UI building blocks of Angular applications. They combine:- A TypeScript class with application logic
- An HTML template that defines the view
- CSS styles for appearance
- Metadata that tells Angular how to process the class
Dependency Injection
Angular’s dependency injection system allows you to declare dependencies in class constructors. The framework automatically provides instances when needed, promoting loose coupling and testability.Lifecycle Hooks
Components and directives have lifecycle hooks that provide visibility into key moments:- Initialization (
OnInit) - Change detection (
OnChanges,DoCheck) - View and content queries (
AfterViewInit,AfterContentInit) - Cleanup (
OnDestroy)
API Categories
Component
Define components with templates and styling
Directive
Create reusable DOM behaviors
Injectable
Enable dependency injection for services
Input & Output
Define component communication interfaces
Lifecycle Hooks
React to component lifecycle events
Common Imports
Standalone Components
Starting with Angular 14, components can be standalone, eliminating the need for NgModules:Signal-Based APIs
Angular 16+ introduces signal-based reactivity:input()- Signal-based input propertiesoutput()- Signal-based output propertiescomputed()- Derived reactive valueseffect()- Side effects based on signal changes
Related Resources
Components Guide
Learn how to build components
Dependency Injection
Master Angular’s DI system
