List Headline Image
Updated by edureka.co on Apr 29, 2019
 REPORT
edureka.co edureka.co
Owner
15 items   2 followers   0 votes   8 views

Top Angular Interview Questions

In this Angular Interview Questions article, you'll learn the most important Angular Interview Questions and Answers which will set you apart in the interview process in 2019. Angular continues to dominate the arena of the Javascript framework and has proved itself to be a worthy investment for web developers who seek to fast-track their career. No surprises there, Angular is majorly known for its ability to create single-page web applications that encompass three critical components – speed, agility and a strong community backing it up. Angular is known as the Swiss army knife of frontend developers! This is the reason why Angular Certification is the most in-demand certification in scripting domain.

1

What is Angular?

Angular is an open-source front-end web framework. It is one of the most popular JavaScript frameworks that is mainly maintained by Google. It provides a platform for easy development of web-based applications and empowers the front end developers in curating cross-platform applications. It integrates powerful features like declarative templates, an end to end tooling, dependency injection and various other best practices that smoothens the development path.

2

What are the advantages of using Angular?

A few of the major advantages of using Angular framework are listed below:

It supports two-way data-binding
It follows MVC pattern architecture
It supports static template and Angular template
You can add a custom directive
It also supports RESTfull services
Validations are supported
Client and server communication is facilitated
Support for dependency injection
Has strong features like Event Handlers, Animation, etc.

3

What is Angular mainly used for?

Angular is typically used for the development of SPA which stands for Single Page Applications. Angular provides a set of ready-to-use modules that simplify the development of single page applications. Not only this, with features like built-in data streaming, type safety, and a modular CLI, Angular is regarded as a full-fledged web framework.

4

Explain the concept of scope hierarchy?

The $scope objects in Angular are organized into a hierarchy and are majorly used by views. It contains a root scope which can further contain scopes known as child scopes. One root scope can contain more than one child scopes. Here each view has its own $scope thus the variables set by its view controller will remain hidden to the other controllers. The Scope hierarchy generally looks like:

Root $scope
$scope for Controller 1
$scope for Controller 2
..
$scope for Controller ‘n’

5

Explain jQLite.

jQlite is also known as jQuery lite is a subset of jQuery and contains all its features. It is packaged within Angular, by default. It helps Angular to manipulate the DOM in a way that is compatible cross-browser. jQLite basically implements only the most commonly needed functionality which results in having a small footprint.

6

What are the different types of filters in Angular?

Below are the various filters supported by Angular:

currency: Format a number to a currency format.
date: Format a date to a specified format.
filter: Select a subset of items from an array.
json: Format an object to a JSON string.
limit: To Limits an array/string, into a specified number of elements/characters.
lowercase: Format a string to lower case.
number: Format a number to a string.
orderBy: Orders an array by an expression.
uppercase: Format a string to upper case.

7

What is bootstrapping in Angular?

Bootstrapping in Angular is nothing but initializing, or starting the Angular app. Angular supports automatic and manual bootstrapping.

Automatic Bootstrapping: this is done by adding the ng-app directive to the root of the application, typically on the tag or tag if you want angular to bootstrap your application automatically. When Angular finds ng-app directive, it loads the module associated with it and then compiles the DOM.
Manual Bootstrapping: Manual bootstrapping provides you more control on how and when to initialize your Angular application. It is useful where you want to perform any other operation before Angular wakes up and compile the page.

8

In Angular, describe how will you set, get and clear cookies?

For using cookies in Angular, you need to include a module called ngCookies angular-cookies.js.

To set Cookies – For setting the cookies in a key-value format ‘put’ method is used.

cookie.set('nameOfCookie',"cookieValue");
To get Cookies – For retrieving the cookies ‘get’ method is used.

cookie.get(‘nameOfCookie’);
To clear Cookies – For removing cookies ‘remove’ method is used.

cookie.delete(‘nameOfCookie’);

9

If your data model is updated outside the ‘Zone’, explain the process how will you the view?

You can update your view using any of the following:

ApplicationRef.prototype.tick(): It will perform change detection on the complete component tree.
NgZone.prototype.run(): It will perform the change detection on the entire component tree. Here, the run() under the hood will call the tick itself and then parameter will take the function before tick and executes it.
ChangeDetectorRef.prototype.detectChanges(): It will launch the change detection on the current component and its children.

10

What is the process of inserting an embedded view from a prepared TemplateRef?

@Component({
selector: 'app-root',
template:
{{name}}

})
export class AppComponent implements AfterViewChecked {
@ViewChild('template', { read: TemplateRef }) _template: TemplateRef;
constructor() { }

ngAfterViewChecked() {
    this.vc.createEmbeddedView(this._template, {fromContext: 'John'});
}

}

11

How can you hide an HTML element just by a button click in angular?

An HTML element can be easily hidden using the ng-hide directive in conjunction along with a controller to hide an HTML element on button click.

View

Hide element
Hello World!

Controller

controller: function() {
this.isHide = false;
this.hide = function(){
this.isHide = true; }; }

12

What are Angular expressions?

Angular expressions are code snippets that are usually placed in binding such as {{ expression }} similar to JavaScript. These expressions are used to bind application data to HTML

Syntax: {{ expression }}

13

In Angular what is string interpolation?

String interpolation in Angular is a special syntax that uses template expressions within double curly {{ }} braces for displaying the component data. It is also known as moustache syntax. The JavaScript expressions are included within the curly braces to be executed by Angular and the relative output is then embedded into the HTML code. These expressions are usually updated and registered like watches, as a part of the digest cycle.

14

What is the difference between an Annotation and a Decorator in Angular?

Annotations in angular are “only” metadata set of the class using the Reflect Metadata library. They are used to create an “annotation” array. On the other hand, decorators are the design patterns that are used for separating decoration or modification of a class without actually altering the original source code.

15

What is the purpose of a filter in Angular?

Filters in Angular are used for formatting the value of an expression in order to display it to the user. These filters can be added to the templates, directives, controllers or services. Not just this, you can create your own custom filters. Using them, you can easily organize data in such a way that the data is displayed only if it fulfills certain criteria. Filters are added to the expressions by using the pipe character |, followed by a filter.

To continue reading more questions like these, click here.