Category: Angular Interview Questions

https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQWVFjQ5rCH3w8I5JUGiE_GcKNaE-Wy_loi_w&s

  • What is the PipeTransform interface?

    As the name suggests, the interface receives an input value and transforms it into the desired format with a transform() method. It is typically used to implement custom pipes.

    import { Pipe, PipeTransform } from '@angular/core';
    
     @Pipe({
    
      name: 'demopipe'
    
    })
    
    export class DemopipePipe implements PipeTransform {
    
      transform(value: unknown, ...args: unknown[]): unknown {
    
    
    return null;
    } }
  • What are Pipes in Angular? 

    angular pipes

    Pipes are simple functions designed to accept an input value, process, and return as an output, a transformed value in a more technical understanding. Angular supports several built-in pipes. However, you can also create custom pipes that cater to your needs. 

    Some key features include: 

    1. Pipes are defined using the pipe “|” symbol. 
    2. Pipes can be chained with other pipes.
    3. Pipes can be provided with arguments by using the colon (:) sign.
  • What are Components in Angular?

    Components Heirarchy

    Components are the basic building blocks of the user interface in an Angular application. Every component is associated with a template and is a subset of directives. An Angular application typically consists of a root component, which is the AppComponent, that then branches out into other components creating a hierarchy.

  • What is an AOT compilation? What are its advantages?

    The Ahead-of-time (AOT) compiler converts the Angular HTML and TypeScript code into JavaScript code during the build phase, i.e., before the browser downloads and runs the code.

    Some of its advantages are as follows. 

    1. Faster rendering
    2. Fewer asynchronous requests
    3. Smaller Angular framework download size
    4. Quick detection of template errors
    5. Better security
  • What are Directives in Angular?

    Directives are attributes that allow the user to write new HTML syntax specific to their applications. They execute whenever the Angular compiler finds them in the DOM. Angular supports three types of directives.  

    1. Component Directives
    2. Structural Directives
    3. Attribute Directives 
  • What are Annotations in Angular?

    Annotations in Angular create an annotation array. They are the metadata set in the class that reflects the metadata library.

  • What are Templates in Angular?

    Angular Templates are written with HTML that contains Angular-specific elements and attributes. In combination with the model and controller’s information, these templates are further rendered to provide a dynamic view to the user.

  • What are the new updates with Angular10? 

    angular
    • Older versions of TypeScript not supported – Previous versions of Angular supported typescript 3.6, 3.7, and even 3.8. But with Angular 10, TypeScript bumped to TypeScript 3.9.
    • Warnings about CommonJS imports – Logging of unknown property bindings or element names in templates is increased to the “error” level, which was previously a “warning” before.
    • Optional strict setting – Version 10 offers a stricter project setup when you create a new workspace with ng new command.

    ng new –strict

    NGCC Feature – Addition of NGCC features with a program based entry point finder. 

    • Updated URL routing
    • Deprecated APIs – Angular 10 has several deprecated APIs.
    • Bug fixes – With this Angular 10 version, there have been a number of bug fixes, important ones being the compiler avoiding undefined expressions and the core avoiding a migration error when a nonexistent symbol is imported.
    • New Default Browser Configuration – Browser configuration for new projects has been upgraded to outdo older and less used browsers. 
  • Mention some advantages of Angular.

    Some of the common advantages of Angular are – 

    1. MVC architecture – Angular is a full-fledged MVC framework. It provides a firm opinion on how the application should be structured. It also offers bi-directional data flow and updates the real DOM. 
    2. Modules: Angular consists of different design patterns like components, directives, pipes, and services, which help in the smooth creation of applications.
    3. Dependency injection: Components dependent on other components can be easily worked around using this feature. 
    4. Other generic advantages include clean and maintainable code, unit testing, reusable components, data binding, and excellent responsive experience.
  • What are decorators in Angular? 

    Decorators are a design pattern or functions that define how Angular features work. They are used to make prior modifications to a class, service, or filter. Angular supports four types of decorators, they are:

    1. Class Decorators
    2. Property Decorators
    3. Method Decorators
    4. Parameter Decorators