Fazrin/Angular Interview Questions and Answers Part 1

Created Wed, 21 Sep 2022 09:59:03 +0530 Modified Fri, 22 Dec 2023 18:51:58 +0000

“Angular Logo”

Q1. What is Angular 4 and how it differs from Angular 1.x?

Q2. What is component decorators in Angular 4?

The main objectives of decorators is to add some metadata to the class that will tell Angular 4 how to process a class. Or in another words, Decorators are functions that modify JavaScript classes. Angular has many decorators that attach metadata to classes so that it knows what those classes mean and how they should work.

Immediately after this decorator or right to it, we need to export a class where our variables and functions reside that our component uses.

  export class sampleComponent{
      name:'Angular 4';
  }

Q3. What is compilation in Angular 4? And what are the types of compilation in Angular 4?

Q4. What is @NgModule?

An NgModule class describes how the application parts fit together. Every application has at least one NgModule, the root module that we bootstrap to launch the application.

import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {AppComponent} from './app.component';

@NgModule({
    imports : [BrowserModule],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})

export class AppModule{}

Here the AppComponent is the root module of our application that Angular creates and inserts it into the index.html page.

Q5. What are all the metadata properties of NgModule? And what are they used for?

@NgModule accepts a metadata object that tells Angular how to compile and launch the application. The properties are:

Q6. What is Template reference variables?

A template reference variable (#var) is a reference to a DOM element within a template. We use hash symbol (#) to declare a reference variable in a template

<input #name placeholder="Your Name"> 
{{name.value}}
Some more set of questions will be posted in next part