Interview Questions Angular - amitbhilagude/userfullinks GitHub Wiki

  1. Why angular so popular
    1. No more DOM manipulation which javascript and jquery used to. Angular Takes care of it.
    2. Partial rendering will never refresh the page and gives a good experience for SPA.
    3. Use of typescript gives strong typing for developers and more maintainable code.
  2. Angular Architecture
    1. Module
      1. Components
        1. View- Template
        2. Component - Class which contains business logic
        3. Both are bound to the property or event binding
      2. Services
        1. Doesn't have UI and injectable in Components.
  3. SPA
    1. One HTML renders from Server
    2. Angular components get renders based on each view.
  4. Angular starter app or basic app
    1. ng new myapp
  5. Angular Starter flow
    1. Index.html: It has reference of app-root component. Runtime refers main.js
    2. Main.ts: It is transpired to the main.js. it has the functionality to bootstrap the main module.
    3. Main Module: The main module has app-root components and views from it will get rendered.
  6. Metadata
    1. Metadata in angular is to inform Angular on how to proceed.
    2. It has annotations like @ e.g. @Ngmodule, @component, @injectable. These annotations are called Decorator.
  7. Constructor vs ngOninit
    1. Constructor is from typescript concept and it gets called when an object gets initialized,
    2. ngonit is an angular page hook life cycle. In terms of flow constructor gets called and the ngonit when the component gets rendered. Any property you want to access from view then it needs to defined in a ngonit.
  8. Angular Page hook life cycle
    1. Similar to .net where every angular component has life cycle events.
    2. They are categorized into two. First time and any change in UI. ngonit for the first time. ngchanges is for any UI-level updates.
  9. Angular Directive
    1. Anything tag added in UI is directive e.g. Ngif, ngfor, etc. They are used to manipulate DOM elements
    2. Three types
      1. Structural Directive: It used to change the structure DOm e.g. Ngfor going to add additional HTML tags in dom
      2. Behaviour Directive: It used to change the behavior of directive e.g. ng-hide will hide the dom
      3. Component directive: Custom directive created for angular. e.g. Usercontrol
  10. Angular dependency Injection and Services.
    1. Explain how dependency injection works and how services are used in the dependency injection pattern.
  11. Httpclient
    1. Subscriber and observable
  12. Lazy Loading
    1. Load on demand.
    2. THis is implemented for modules only and if you wish to load a module dynamically on demand.
    3. It is implemented using routing where Route has a path which will bound to component and Lazyload property where we can provide module relative path.
  13. Canactivate
    1. This specifically used for routing and if you wish to activate the route based on a certain condition
    2. It can method and based on the return type of method. It can be decided