Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PradeepLoganathan/0231073309d80248f5a99519b221e2e9 to your computer and use it in GitHub Desktop.
Save PradeepLoganathan/0231073309d80248f5a99519b221e2e9 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment