Friday, May 18, 2018

1.What is Angular 2?
--------------------------
Answer:Angular is a platform and framework for building client applications in HTML and TypeScript. Angular is itself written in TypeScript. It implements core and optional functionality as a set of TypeScript libraries that you import into your apps.

The basic building blocks of an Angular application are NgModules, which provide a compilation context for components. NgModules collect related code into functional sets; an Angular app is defined by a set of NgModules. An app always has at least a root module that enables bootstrapping, and typically has many more feature modules.

2.What is Component is Angular 2 ?
--------------------------------------------
Answer:A component in Angular is a class with a template and a decorator. So in simple terms a component in Angular is composed of these 3 things
Template - Defines the user interface. Contains the HTML, directives and bindings.
Class - Contains the code required for template. Just like a class in any object oriented programming language like C# or Java, a class in angular can contain methods and properties. Properties contain the data that we want to display in the view template and methods contain the logic for the view. We use TypeScript to create the class.
Decorator - We use the Component decorator provided by Angular to add metadata to the class. A class becomes an Angular component, when it is decorated with the Component decorator.

3.What are the differences between template and templateUrl properties and when to use one over the other
--------------------------------------------------------------------------------------------------------------------------
Answer:Angular2 recommends to extract templates into a separate file, if the view template is longer than 3 lines. Let's understand why is it better to extract a view template into a seprate file, if it is longer than 3 lines.
With an inline template
We loose Visual Studio editor intellisense, code-completion and formatting features.
TypeScript code is not easier to read and understand when it is mixed with the inline template HTML.
With an external view template
We have Visual Studio editor intellisense, code-completion and formatting features and
Not only the code in "app.component.ts" is clean, it is also easier to read and understand

4.What is Traceur Compiler?
----------------------------------
Answer:Traceur is a compiler which takes ECMAScript and compiles it down to regular Javascript that runs in your browser. Traceur can be used in several ways like- typing or pasting the ES6 code into the read-eval-print-loop page, or by including traceur in the web page and compiling ES6 code content on the fly, or many other ways. Even traceur is written in ES6, compiled to ES5. The main goal of a traceur compiler is to inform the designs of Javascript features and allows us to write the code in a better manner. Nowadays, traceur compilers are broadly used in Angular 2 platform

5.List the modern browsers supported by Angular 2.
--------------------------------------------------------------
Answer:Angular supports most of the recent browsers some of which are-

Google Chrome
Firefox
Edge
IE for versions 9-11
Safari
iOS 7.1
Android 4.1

6.What do you mean by a structural directive in Angular 2?
---------------------------------------------------------------------
Answer:Structural directives are used to manipulate DOM in angular. Structural directives are responsible for HTML layout. By adding, removing, or manipulating LMNs in angular, they shape or reshape the structure of DOM. This structural directive is applied to a host element with the help of other directives. The directives then do whatever it is supposed to do with that host element and its descendants. Structural directives can be easily recognized. It can also delay the instantiation of a component or an element. It can also be used for cosmetic effect or manually handling the timing of the loading of components. Structural directives are bound to a template. The two most common structural directives are “ngIf” and “ngFor”. The process occurring in a structural directive is dynamic.

7.List the key components of Angular 2?
------------------------------------------------
Answer:The Angular 2 comprises of the following key components:

Module – This is used to break the application into the logical pieces of the program code and each piece of code or module is designed to perform a single and unique task.
Component – This is used to bring the modules together.
Templates – This is used to define the Views of an Angular JS application.
Metadata – This is used to add more data to an Angular JS application.
Service – This component is used to develop the components, which can be used to share in the entire application.

8.What is AOT compilation?
-----------------------------------
Answer:AOT stands for Ahead of Time.It is the compilation in which Angular compiles the components and templates to JavaScript and HTML while developing.

Advantages
Faster download: Since the app is already compiled, many of the angular compiler related libraries are not required to be bundled, the app bundle size get reduced. So, the app can be downloaded faster.
Lesser No. of Http Requests: If the app is not bundled to support lazy loading (or whatever reasons), for each associated html and css, there is a separate request goes to the server. The pre-compiled application in-lines all templates and styles with components, so the number of Http requests to the server would be lesser.
Faster Rendering: If the app is not AOT compiled, the compilation process happens in the browser once the application is fully loaded. This has a wait time for all necessary component to be downloaded, and then the time taken by the compiler to compile the app. With AOT compilation, this is optimized.
Detect error at build time: Since compilation happens beforehand, many compile time error can be detected, providing a better degree of stability of application.

No comments:

Post a Comment

How To Add DateRange Picker In Angular Application

  Introduction   In this article, we will learn how to add date range picker In Angular application.   Prerequisites Basic Knowledge of Angu...