Angular Interview Questions and Answers Set 3

21.What are pure Pipes?

Angular pipes are simple functions that transform the format of output data.Pure pipes are pipes that are executed when pure change is detected in the input value. It employs pure functions.

22. What is main differences between Angular expression and JavaScript expression?

Angular expressions are evaluated against a scopeobject. JavaScript expressions are evaluated against the global window. In Angular, expression evaluation is forgiving to undefined and null. JavaScript expression try to evaluate undefined properties generates ReferenceError or TypeError.

23. Explain Es5 vs Es6 difference?

ES6 class basically does the work of defining a new object and appending functions to its prototype. ES5 Function constructors work and look the same but the main difference is observed when the developer uses the Inheritance property. ES6 class allows the developers to instantiate objects using the new operator.

24. Explain the process how do we exchange the data from front end to server?

import { HttpModule } from ‘@angular/http’; @NgModule({ declarations: [], imports: [HttpModule] If you are using HttpClientModule make changes accordingly.

25. What is compilation in Angular? What types of compilations are used in Angular?

The Angular compilation process begins after your HTML page (static DOM) is fully loaded.There are two types of compilations in Angular: Just-in-time (JIT) compilation: This is a standard development approach which compiles our Typescript and html files in the browser at runtime, as the application loads.

ANGULAR TRAINING
Weekend / Weekday Batch

 

26. What is the difference between Angular and React?

Angular is an open-source JavaScript framework that is written in TypeScript. React is an open-source JavaScript library that was developed by Facebook. It is based on JSX (an extension of PHP) and JavaScript.

The React Library divides the webpage into single components and simplifies the development of the interface.

27. What is metadata in Angular?

Metadata is used to decorate a class so that it can configure the expected behavior of the class. The component decorator is used to declare the class in the app. component.

When we configure a component, we can are providing a metadata for that class that tells Angular that you have a component, and that component has a specific configuration.

28. What does SPA (Single page application) mean?

SPA is a concept where rather loading pages from the server by doing post backs we create a single shell page or master page and load the webpages inside that master page.

29. What are controllers in AngularJS?

A Controller is a set of JavaScript functions which is bound to a specified scope, the ng-controller directive. Angular creates a new instance of the Controller object to inject the new scope as a dependency. The role of the Controller is to expose data to our view via $scope and add functions to it, which contains business logic to enhance view behavior.

Controller Rules.

A Controller helps in setting up the initial state of the scope object and define its behavior.

The Controller should not be used to manipulate the DOM as it contains only business logic. Rather, for manipulating the DOM, we should use data binding and directives.

Do not use Controllers to format input. Rather, using angular form controls is recommended for that.

Controllers should not be used to share code or states. Instead, use angular services for it.

Steps For Creating A Controller.

It needs ng-controller directive.

Next step is to add Controller code to a module.

Name your Controller based on functionality. Its name should follow camel case format (i.e. SampleController).

Set up the initial state of the scope object.

Declaring a Controller using ng-Controller directive.

Following code displays the definition of SampleController.

<script>
function SampleController($scope) {
$scope.sample = {firstSample: “INITIAL”,  lastSample: “Initial”,  fullName: function() {
var sampleObject;
sampleObject = $scope.sample;
return sampleObject.firstSample + ” ” + sampleObject.lastSample;
}
};
}</script>

30. What are template expressions in Angular?

A template expression produces a value and appears within double curly braces, {{ }} . Angular resolves the expression and assigns it to a property of a binding target. The target could be an HTML element, a component, or a directive.