Monday, July 15, 2024

Angular Core

 What are hooks in angular?

  • When a new component is created in angular, it goes through many phases, each phase has a call back attached to it.
  • The callbacks are called in Following order
    • Constructor
    • ngOnChanges()
    • ngOnInit()
    • ngOnDoCheck()
    • ngAfterContentInit()
What is a service in angular?
  • A Service is used by multiple components
  • It helps to avoid duplication of code, thus avoiding DRY principle(Do not repeat yourself).
  • Separate component Presentation, logic from business logic.

Sunday, September 13, 2020

Angular Modules

Q Difference between Browser Module and platformBrowserDynamicModule?
  1. A platformBrowserDynamic is a function used to bootstrap an Angular Application.
  2. CommonModule is a module that provides all kinds of services and directives one usually wants to use in an Angular 2 application like ngIf
    1. Common module is platform-independent
  3. Browser Module exports CommonModule and provides a few services specific to the Browser platform.
    1. Browser Module should only be imported in App Module.
    2. Common Module can be imported Anywhere.