Top 100 Angular interview questions

  1. Components & Templates

1)What is a component in Angular?

2)How do you define a component?

3)What is the role of the selector in a component?

4)How do you use @Input() and @Output()?

5)What is the difference between ngIf, ngFor, and ngSwitch?

6)What is the use of template reference variables?

7)How do you pass data from parent to child component?

8)How do you emit data from child to parent?

9)What is the purpose of ng-content?

10)How do you use content projection in Angular?

🔹 2. Lifecycle Hooks

11)What are Angular lifecycle hooks?

12)What is ngOnInit()?

13)When is ngOnChanges() called?

14)What is ngAfterViewInit() and ngAfterContentInit()?

15)What is the use of ngOnDestroy()?

🔹 3. Modules & Architecture

16)What is an Angular module?

17)Difference between root module and feature module?

18)What is a shared module?

19)What is lazy loading in Angular?

20)How do you configure lazy loading?

🔹 4. Services & Dependency Injection

21)What is a service in Angular?

22)How do you create and inject a service?

23)What is dependency injection?

24)What is the difference between providedIn: 'root' vs module-level providers?

25)What are hierarchical injectors?

🔹 5. Directives

26)What are Angular directives?

27)What is the difference between structural and attribute directives?

28)How do you create a custom directive?

29)What is the purpose of ngClass and ngStyle?

30)How does *ngIf differ from [hidden]?

🔹 6. Pipes

31)What is a pipe in Angular?

32)What are built-in pipes in Angular?

33)How do you create a custom pipe?

34)What is the difference between pure and impure pipes?

35)How do you pass parameters to pipes?

🔹 7. Routing

36)What is the Angular router?

37)How do you configure routes?

38)What are child routes?

39)What are route guards?

40)What is the difference between CanActivate and CanDeactivate?

41)How do you pass route parameters?

42)How do you retrieve query parameters?

43)What is routerLinkActive directive used for?

44)How do you handle 404 routes in Angular?

45)What is the difference between navigate() and navigateByUrl()?

🔹 8. Forms

46)What is the difference between template-driven and reactive forms?

47)How do you create a reactive form?

48)How do you add form validation?

49)How do you implement custom validators?

50)What is FormGroup, FormControl, and FormArray?

51)How do you update form values dynamically?

52) How do you reset a form?

53) How do you disable a form control?

🔹 9. Observables & RxJS

54) What is an observable?

55) What is a subject?

56) What is the difference between Subject, BehaviorSubject, and ReplaySubject?

57) What is pipe() in RxJS?

58) Explain map(), mergeMap(), switchMap(), and concatMap().

59) What is takeUntil() and why is it important?

60) How do you handle observable unsubscribe?

61) What is debounceTime() used for?

🔹 10. HTTP Client

62) How do you make HTTP calls in Angular?

63) What is HttpClientModule?

64) How do you handle HTTP errors?

65) How do you retry failed requests?

66) What are HTTP interceptors?

67) How do you add headers to an HTTP request?

68) How do you cancel an HTTP request?

🔹 11. Change Detection

69) What is Angular’s change detection?

70) What is the default change detection strategy?

71) What is ChangeDetectionStrategy.OnPush?

72) How does ngZone affect change detection?

73) What is markForCheck() and detectChanges()?

🔹 12. Performance Optimization

74) How do you optimize large Angular apps?

75) What is virtual scrolling?

76) How do you use trackBy in ngFor and why?

77) How do you lazy load images or modules?

78) How do you improve initial load performance?

79) What is preloading strategy in Angular routing?

🔹 13. Security

80) How do you prevent Cross-Site Scripting (XSS) in Angular?

81) What is Angular’s built-in sanitizer?

82) How do you implement authentication in Angular?

83) What is route guard and how do you use it for authorization?

84) How do you store JWT securely in Angular?

🔹 14. Testing

85) How do you write unit tests for components?

86) What is TestBed?

87) How do you mock a service in unit tests?

88) How do you test forms in Angular?

89) How do you test HTTP requests?

90) What is Jasmine and Karma?

91) How do you test pipes and directives?

🔹 15. Miscellaneous

92) What are Angular decorators? Name a few.

93) What is a singleton service?

94) How does Angular handle DOM sanitization?

95) What are template reference variables?

96) What is the Angular CLI and how do you use it?

97) How do you handle environment-specific settings?

98) What is dynamic component loading?

99) What is differential loading?

100) What is zone.js and what role does it play in Angular?

No comments:

Post a Comment