Skip to content

Instantly share code, notes, and snippets.

@amcdnl
Last active October 12, 2023 04:56
Show Gist options
  • Save amcdnl/d1f9995560da80160d64f700d0bd8d7c to your computer and use it in GitHub Desktop.
Save amcdnl/d1f9995560da80160d64f700d0bd8d7c to your computer and use it in GitHub Desktop.

Angular Interview Questions

Some basic questions going from easy to difficult. A more exhaustive list of more questions from the community can be found here.

Easy

  • Whats the difference between components and directives? [ANSWER]: Components are widgets while directives more like decorators for elements and/or components.
  • How do you get a reference to a child component? [ANSWER]: ViewChild/ViewChildren or ContentChild/ContentChildren
  • What is the difference between ViewChild and ContentChild?
  • Whats the difference between NgModules and ES2015 Modules?
  • How do you lazy load components and why is lazy loading important?
  • Explain Observables and why they are useful.
  • What pipe do you use to subscribe to a observable in a template? [ANSWER]: async
  • What are the lifecycle methods in Angular components? [ANSWER]: https://angular.io/guide/lifecycle-hooks
  • How do you listen for events in a component? [ANSWER]: HostListener or via elementRef.nativeElement

Intermediate

  • Explain what OnPush change detection in components is. [ANSWER]: CD is ran when a immutable property is reset vs dirty checking as normal.
  • Whats the difference between template and reactive forms and why would you use one or the other?
  • What is depedency injection and why is it useful?
  • How do you resolve data before a route is loaded? [ANSWER]: Route Resolvers
  • What is ViewEncapsulation?
  • Explain content projection. (ie ng-content)
  • What are route guards and why are they useful?
  • What is Zones? What are they used for?
  • What are auxiliary routes?
  • How do you force a change detection cycle? [ANSWER]: changeDetectorRef.markForCheck OR changeDetectorRef.detectChanges().

Difficult

Whats the different between changeDetectorRef.markForCheck and changeDetectorRef.detectChanges()?

  • What does Expression has changed after it was checked error mean?
  • What is tree shaking?
  • What is ng-container and why is it useful?
  • How would you get a reference to a parent component? [ANSWER]: Inject it in the constructor.
  • What does forwardRef do?
  • What are rxjs letttable operators?
  • What are entryComponents?
  • Explain change detection in Angular?
  • Explain what AoT is and how it differs from JIT?
  • What is Redux pattern and explain why its useful.
  • When building custom form components, what interface do they components need to implement to particpate in forms? [ANSWER]: ControlValueAccessor
@ThomasBurleson
Copy link

How do you listen for events in a component? is a trick question because
you could specify event bindings in the components templates or listen at the host-level.
What is ng-container and why is it useful? i would not consider this an intermediate question... this is senior question.
What are rxjs letttable operators? More importantly ask what the .../add/operator/*.ts imports does.

@codediodeio
Copy link

Why is direct DOM manipulation a bad practice?

What happens when you provide a service in a lazy loaded module? Answer: A new DI branch is created that is not accessible by the root module.

@CNSKnight
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment