Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Angular Interview Questions and Answers

Related differences

Related differences

Angular vs ReactAngularJS vs NodeJSAngularJS vs Angular
Jquery vs AngularJS

Ques 6. What is the difference between AngularJS and Angular?

Angular is a completely revived component-based framework in which an application is a tree of individual components. For tabular view check here:

http://withoutbook.com/DifferenceBetweenSubjects.php?subId1=79&subId2=115&d=Difference%20between%20AngularJS%20and%20Angular

 

Is it helpful? Add Comment View Comments
 

Ques 7. What is TypeScript?

TypeScript is a strongly typed superset of JavaScript created by Microsoft that adds optional types, classes, async/await and many other features, and compiles to plain JavaScript. Angular is written entirely in TypeScript as a primary language. You can install TypeScript globally as:

npm install -g typescript

Let's see a simple example of TypeScript usage:-

function greeter(person: string) {

  return "Hello, " + person;

}

let user = "Arindam";

document.body.innerHTML = greeter(user);

The greeter method allows only string type as argument.

Is it helpful? Add Comment View Comments
 

Ques 8. What are the key components of Angular?

Angular has the key components below,

    1. Component: These are the basic building blocks of an Angular application to control HTML views.
    2. Modules: An Angular module is a set of angular basic building blocks like components, directives, services etc. An application is divided into logical pieces and each piece of code is called as "module" which perform a single task.
    3. Templates: These represent the views of an Angular application.
    4. Services: Are used to create components which can be shared across the entire application.
    5. Metadata: This can be used to add more data to an Angular class.

Is it helpful? Add Comment View Comments
 

Ques 9. What are directives?

Directives add behaviour to an existing DOM element or an existing component instance.

import { Directive, ElementRef, Input } from '@angular/core';

@Directive({ selector: '[myHighlight]' })

export class HighlightDirective {

  constructor(el: ElementRef) {

  el.nativeElement.style.backgroundColor = 'yellow';

  }

}



Now this directive extends HTML element behavior with a yellow background as below:

<p myHighlight>Highlight me!</p>

 

Is it helpful? Add Comment View Comments
 

Ques 10. What are components?

Components are the most basic UI building block of an Angular app which formed a tree of Angular components. These components are subset of directives. Unlike directives, components always have a template and only one component can be instantiated per an element in a template. Let's see a simple example of Angular component:

import { Component } from '@angular/core';

@Component ({

  selector: 'my-app',

  template: ` <div>

  <h1>{{title}}</h1>

  <div>Learn Angular6 with examples</div>

  </div> `,

})

export class AppComponent {

  title: string = 'Welcome to Angular world';

}

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2024 WithoutBook