Overview
The Odontología Frontend application is built using Angular 21 with a modern standalone component architecture. The application eliminates the need for NgModules, embracing a simpler, more streamlined approach to building Angular applications.This application uses Angular’s standalone components exclusively, removing NgModule dependencies and simplifying the component structure.
Standalone Component Architecture
What Are Standalone Components?
Standalone components are self-contained Angular components that declare their own dependencies directly, without requiring an NgModule. This reduces boilerplate and makes components more portable and easier to understand.Root Component
The application’s root component demonstrates the standalone architecture pattern:src/app/app.ts
Key Architecture Features
Dependency Injection with inject()
Dependency Injection with inject()
The application uses the modern This approach is more concise and allows for injection outside of constructors.
inject() function instead of constructor-based injection:Reactive State with Signals
Reactive State with Signals
Angular Signals provide fine-grained reactivity:Signals offer better performance than traditional change detection.
RxJS Interoperability
RxJS Interoperability
The
toSignal() function bridges RxJS observables and Angular signals:Computed Values
Computed Values
Derived state is created using Computed signals automatically recalculate when their dependencies change.
computed():Application Configuration
The application bootstrap configuration is defined inapp.config.ts:
src/app/app.config.ts
Provider Configuration
Global Error Listeners
Captures and handles global errors across the application
Router Provider
Configures the Angular router with the application’s route definitions
Component Structure
Typical Component Pattern
Most components in the application follow this structure:src/app/patient/patient.ts
Component Characteristics
- Standalone: All components use
standalone: true - Explicit Imports: Each component declares its own template dependencies
- Service Injection: Services are injected via constructor or
inject() - Lifecycle Hooks: Standard Angular lifecycle hooks (
OnInit, etc.)
Template Syntax
The application uses Angular’s modern control flow syntax:src/app/app.html
The
@if syntax is Angular’s new built-in control flow, replacing *ngIf for better performance and type safety.Directory Structure
Service Architecture
All services use Angular’sprovidedIn: 'root' pattern for singleton behavior:
- Creates a single instance across the application
- Enables tree-shaking for unused services
- Eliminates the need for provider arrays in modules
Best Practices
Use Signals for Reactive State
Prefer signals over traditional observables for component state
Leverage inject()
Use the modern inject() function for dependency injection
Standalone Components
All new components should be standalone
Explicit Imports
Declare all template dependencies in the imports array
Performance Considerations
Signals vs Observables
Use Signals when:- Managing local component state
- Creating derived/computed values
- Simple synchronous updates
- Handling asynchronous operations
- Working with HTTP requests
- Complex event streams
Change Detection Optimization
The application benefits from Angular’s signal-based change detection:Next Steps
Routing
Learn about the application’s routing configuration
State Management
Explore how state is managed across the application