Q1. What is the architecture of an Angular application?
Angular follows a component-based architecture. The main building blocks are: Modules (NgModules) that organize the application, Components that control views, Templates that define the UI, Data binding that connects component and template, Services that provide business logic, and Dependency injection that provides services to components. The application is bootstrapped by a root module.
Q2. What is the role of NgModule?
NgModule is a decorator that marks a class as an Angular module. It organizes related components, directives, pipes, and services into cohesive blocks. It declares what belongs to the module, imports other modules, exports parts for other modules, and provides services. Every Angular app has at least one module (AppModule).
Q3. How does Angular bootstrapping work?
The bootstrapping process starts in main.ts, which calls platformBrowserDynamic().bootstrapModule(AppModule). This creates a platform, compiles the module in Just-in-Time (JIT) mode (or uses pre-compiled code in AOT), and then bootstraps the root component (AppComponent) specified in the module. The root component is inserted into the index.html.
Q4. What is the role of a component in Angular?
A component controls a portion of the screen (view). It consists of a TypeScript class with properties and methods, an HTML template that defines the view, and styles. Components handle user interaction, data display, and communication with services. They are the most fundamental building blocks of Angular apps.
Q5. What is the purpose of a service in Angular?
Services are singleton objects that encapsulate business logic, data access, or shared functionality. They are typically injected into components using dependency injection. Services can communicate with servers, hold application state, or provide utility methods. This promotes separation of concerns and reusability.
