Angular Interview Questions - Angular Interview Prep
50 Questions Available
Comprehensive collection of 50 essential Angular interview questions covering components, services, routing, directives, and Angular best practices.
All Questions & Answers
What is Angular?
Angular is TypeScript-based web framework for building single-page applications (SPAs). Features: component-based architecture, dependency injection, routing, two-way data binding, directives, services, RxJS for reactive programming. Developed by Google.
What is the difference between AngularJS and Angular?
AngularJS (v1.x) uses JavaScript, controllers, scope, two-way binding. Angular (v2+) uses TypeScript, components, no scope, one-way binding by default, better performance, mobile support, modern architecture. Angular is complete rewrite, not upgrade.
What is a component in Angular?
Component is building block of Angular app. Consists of: class (TypeScript), template (HTML), styles (CSS), metadata (@Component decorator). Encapsulates data, logic, and view. Reusable, composable. Root component bootstraps application.
What is a module in Angular?
Module (@NgModule) organizes application into cohesive blocks. Declares components, directives, pipes. Imports other modules. Exports for other modules. Provides services. Root module (AppModule) bootstraps app. Feature modules organize by feature.
What is data binding in Angular?
Data binding connects component data with template. Types: interpolation {{ }}, property binding [ ], event binding ( ), two-way binding [( )]. One-way by default (component to view). Two-way requires FormsModule. Enables dynamic UI updates.
What is a directive?
Directive modifies DOM or component behavior. Types: component (with template), structural (*ngIf, *ngFor), attribute ([ngClass], [ngStyle]). Structural directives change DOM structure. Attribute directives change appearance/behavior. Can create custom directives.
What is a service in Angular?
Service is class with specific purpose, provides functionality to components. Injectable via dependency injection. Singleton by default (one instance per injector). Uses: data fetching, business logic, shared state, logging. Created with @Injectable decorator.
What is dependency injection?
Dependency injection provides dependencies to classes rather than creating them. Angular creates and manages instances. Benefits: testability, maintainability, loose coupling. Inject via constructor. Configure in providers array or providedIn: root.
What is routing in Angular?
Routing enables navigation between views. Configure routes in Routes array. RouterModule provides router directives and service. Use routerLink for navigation, router-outlet for displaying routed components. Supports lazy loading, guards, parameters.
What are Angular lifecycle hooks?
Lifecycle hooks are methods called at specific points in component lifecycle. Order: ngOnChanges, ngOnInit, ngDoCheck, ngAfterContentInit, ngAfterContentChecked, ngAfterViewInit, ngAfterViewChecked, ngOnDestroy. Implement OnInit, OnDestroy most commonly.