1. Angular Framework
Angular is a TypeScript-based open-source front-end framework maintained by Google. It helps developers build scalable single-page applications (SPAs) with two-way data binding, dependency injection, routing, and modular architecture. Angular follows MVC-like patterns and provides reusable components and services.
2. Angular Modules
Definition:
Modules are containers that group related components, directives, services, and pipes. Every Angular app has a root module (AppModule) and can have multiple feature modules for modularity. They improve maintainability and lazy loading.
Example (app.module.ts):
3. Components
Definition:
Components are building blocks of Angular apps. They control a part of the UI using HTML templates, CSS styles, and TypeScript logic. Each component is associated with a selector used in HTML.
Example (course-card.component.ts):
4. Services
Definition:
Services hold business logic and data retrieval logic. They are reusable across components and injected via Angular’s Dependency Injection (DI) system.
Example (courses.service.ts):
5. Templates
Definition:
Templates define the view (UI) of a component using HTML and Angular syntax like interpolation ({{ }}), property binding, event binding, and structural directives.
Example (course-card.component.html):
6. Pipes
Definition:
Pipes transform data before displaying it in templates. Angular provides built-in pipes like date, currency, uppercase, and we can create custom pipes.
Example:
Custom Pipe (truncate.pipe.ts):
7. Routing
Definition:
Routing allows navigation between different views (components) without reloading the page. It defines paths mapped to components.
Example (app-routing.module.ts):
8. Directives
Definition:
Directives are instructions in the DOM that add behavior to elements.
-
Structural Directives: Change DOM structure (
*ngIf,*ngFor). -
Attribute Directives: Change DOM appearance/behavior (
ngStyle,ngClass). -
Custom Directives: Developer-defined logic.
Example – Built-in:
9. Decorators in Angular
Definition:
Decorators add metadata to classes, properties, and methods. They tell Angular how to process a class or element.
1. @NgModule
-
Defines a module that bundles components, directives, pipes, and services.
-
Every Angular app has a root module (
AppModule). -
Helps organize the application into functional blocks.
2. @Component
-
Declares a component (UI + logic).
-
Connects HTML template, CSS styles, and TypeScript logic.
3. @Injectable
-
Declares a service available for Dependency Injection.
-
Ensures the class can be injected into components or other services.
4. @Directive
-
Creates a custom directive (structural or attribute).
5. @Pipe
-
Defines a custom pipe to transform data.
6. @Input / @Output
-
@Input → Pass data from parent to child component.
-
@Output → Send events from child to parent.
7. @HostListener / @HostBinding
-
@HostListener → Listen to DOM events.
-
@HostBinding → Bind properties to host element.
8. @ViewChild / @ViewChildren
-
Access template DOM elements or child components.
9. @ContentChild / @ContentChildren
-
Access projected content inside
<ng-content>.
10. Dependency Injection Decorators
-
@Optional → Service may or may not exist.
-
@Self → Look only in current injector.
-
@SkipSelf → Look in parent injector.
-
@Host → Look in host component injector.
Common Angular Decorators:
-
@Component → Defines a component.
-
@NgModule → Defines a module.
-
@Injectable → Marks a service for DI.
-
@Directive → Defines a custom directive.
-
@Pipe → Defines a custom pipe.
-
@Input → Pass data from parent → child.
-
@Output → Emit events child → parent.
-
@HostListener → Listen to DOM events.
-
@ViewChild / @ViewChildren → Access child elements/components.
Example (Input/Output):
10. Project Architecture (src/app folder)
11. Angular Architecture Flow (Diagram – textual form)
12. MVC Mapping in Angular
-
Model: Data models (
Courseclass), services (CourseService). -
View: Templates (
.html), directives, and pipes controlling UI. -
Controller: Components (
.ts) act as controllers connecting Model & View.
MVC Diagram (textual form):
Amazing your words will help me to work in the future. Learn more html dd https://beginnerwebdeveloper.com/blog/html-dd/
ReplyDeletehtml dd tag
ReplyDelete