
1. What is Angular and why is it used?
Angular is a TypeScript-based front-end framework developed by Google. It helps build dynamic, single-page web applications (SPAs) with modular architecture and efficient data binding.
2. What are the key features of Angular?
Angular offers powerful features like two-way data binding, dependency injection, component-based architecture, routing, and built-in directives for dynamic UI control.
3. What is the difference between AngularJS and Angular?
AngularJS (v1.x) is based on JavaScript, while Angular (v2+) uses TypeScript. Angular is faster, supports mobile development, and follows a component-based structure unlike AngularJS’s MVC pattern.
4. What are components in Angular?
Components are the building blocks of Angular applications. Each component consists of a TypeScript class, an HTML template, and optional CSS styles.
5. What is data binding in Angular?
Data binding connects the component logic with the UI. Angular supports one-way and two-way binding using syntax like {{}}
, [property]
, and [(ngModel)]
.
6. What is dependency injection in Angular?
Dependency Injection (DI) is a design pattern where Angular automatically provides required services to components, improving modularity and testability.
7. What are directives in Angular?
Directives are special markers in templates that tell Angular to perform specific actions. Examples include *ngIf
for conditionals and *ngFor
for loops.
8. What is Angular CLI and why is it useful?
Angular CLI is a command-line tool that simplifies Angular development by generating components, services, and modules, and managing builds and testing.
npm install -g @angular/cli
9. What are services in Angular?
Services are reusable classes that handle business logic, data fetching, and shared functionality across components. They are injected using Angular’s DI system.
10. What is routing in Angular?
Routing enables navigation between views or components. Angular uses the RouterModule
to define routes and manage URL changes.
11. What is the difference between observable and promise?
Promises handle a single asynchronous event, while Observables (from RxJS) support multiple values over time and offer operators for transformation and cancellation.
12. What is a module in Angular?
Modules group related components, directives, pipes, and services. The root module is AppModule
, and feature modules help organize large applications.
13. How does Angular handle forms?
Angular supports two types of forms: Template-driven (easy to use) and Reactive (more control and validation). Reactive forms use FormGroup
and FormControl
.
14. What is change detection in Angular?
Change detection is the mechanism Angular uses to track and update the DOM when data changes. It runs automatically after events, HTTP calls, or user input.
15. How do you optimize performance in Angular apps?
Use lazy loading for modules, OnPush change detection strategy, trackBy in *ngFor
, and avoid unnecessary DOM updates to improve performance.
Search
Categories
Recent Posts
Top Git interview Questions for Experienced Developer
Speed-up tips and tricks for Windows 11
Top 15 Linux Commands used by Experienced Developer
Top SQL Interview Examples for Experienced Developer
Internal Working of Java HashMap
Recent Tags