This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Difference Between Constructor And Ngoninit? |
|
Answer» DIFFERENCES - CONSTRUCTOR Vs. ngOnInit ANGULAR 2 Constructors:-
Angular 2 ngOnInit:-
Differences - Constructor Vs. ngOnInit Angular 2 Constructors:- Angular 2 ngOnInit:- |
|
| 2. |
What Are The Core Differences Between Observables And Promises? |
|
Answer» PROMISES vs Observables : Promises: Observables:
Promises vs Observables : Promises: Observables: |
|
| 3. |
What Are The Advantages And Disadvantages Of Aot Compilation? |
|
Answer» Advantages :
Disadvantages
Advantages : Disadvantages |
|
| 4. |
What Is Aot Compilation? |
|
Answer» AOT compilation stands for Ahead Of TIME compilation, in which the angular compiler compiles the angular COMPONENTS and templates to native JavaScript and HTML during the BUILD time. The compiled Html and JavaScript is deployed to the WEB server so that the compilation and render time can be saved by the browser. AOT compilation stands for Ahead Of Time compilation, in which the angular compiler compiles the angular components and templates to native JavaScript and HTML during the build time. The compiled Html and JavaScript is deployed to the web server so that the compilation and render time can be saved by the browser. |
|
| 5. |
What Is Shadow Dom? How Is It Helping Angular 2 To Perform Better? |
|
Answer» Shadow DOM is a part of the HTML spec which allows developers to encapsulate their HTML markup, CSS styles and JavaScript. Shadow DOM, along with a few other technologies, gives developers the ability to build their own 1st class tags, web components and APIs just like the <audio> tag. Collectively, these new tags and APIs are referred to as Web Components. Shadow DOM provides better separation of concern along with lesser conflict of styles and scripts with other HTML DOM ELEMENTS. Since shadow DOM are static in nature, it’s a GOOD candidate to be cached as it is not accessible to developer. The cached DOM would be RENDERED faster in the browser providing better PERFORMANCE. Moreover, shadow DOM can be managed comparatively well while detecting the change in angular 2 application and re-paint of view can be managed efficiently. Shadow DOM is a part of the HTML spec which allows developers to encapsulate their HTML markup, CSS styles and JavaScript. Shadow DOM, along with a few other technologies, gives developers the ability to build their own 1st class tags, web components and APIs just like the <audio> tag. Collectively, these new tags and APIs are referred to as Web Components. Shadow DOM provides better separation of concern along with lesser conflict of styles and scripts with other HTML DOM elements. Since shadow DOM are static in nature, it’s a good candidate to be cached as it is not accessible to developer. The cached DOM would be rendered faster in the browser providing better performance. Moreover, shadow DOM can be managed comparatively well while detecting the change in angular 2 application and re-paint of view can be managed efficiently. |
|
| 6. |
How Would You Define Custom Typings To Avoid Editor Warnings? |
|
Answer» Well, in most of the CASES, the 3RD party library comes with its own .d.ts file for its type definition. In some cases, we need to extend the existing type by PROVIDING some more properties to it or if we need to define additional types to avoid Typescript warning. If we need to extend the type definition for external library, as a good PRACTICE, we should not touch the node_modules or existing typings folder. We can create a new folder, say “custom-typings” and keep all customized type definition in that. To define typings for application (JavaScript/Typescript) objects, we should define interfaces and entity classes in models folder in the respective module of the application. For those cases, we can define or extend the types by creating our own “.d.ts” file. Well, in most of the cases, the 3rd party library comes with its own .d.ts file for its type definition. In some cases, we need to extend the existing type by providing some more properties to it or if we need to define additional types to avoid Typescript warning. If we need to extend the type definition for external library, as a good practice, we should not touch the node_modules or existing typings folder. We can create a new folder, say “custom-typings” and keep all customized type definition in that. To define typings for application (JavaScript/Typescript) objects, we should define interfaces and entity classes in models folder in the respective module of the application. For those cases, we can define or extend the types by creating our own “.d.ts” file. |
|
| 7. |
How Would You Optimize The Angular 2 Application For Better Performance? |
|
Answer» ell, OPTIMIZATION depends on the type and SIZE of APPLICATION and many other factors. But in general, I would CONSIDER the following points while optimizing the angular 2 app:
ell, optimization depends on the type and size of application and many other factors. But in general, I would consider the following points while optimizing the angular 2 app: |
|
| 8. |
What Is The Use Of Codelyzer In Angular 2 Application.? |
|
Answer» All enterprise applications follows a set of coding conventions and guidelines to maintain code in better way. CODELYZER is an open source tool to run and check whether the pre-defined coding guidelines has been followed or not. Codelyzer does only static code analysis for ANGULAR and typescript project. Codelyzer runs on top of tslint and its coding conventions are usually defined in tslint.json file. Codelyzer can be run via angular cli or NPM directly. Editors like Visual Studio Code and Atom also supports codelyzer just by doing a basic settings. To set up the codelyzer in Visual Studio code, we can go to File -> Preferences -> User Settings and add the PATH for tslint rules. Hide Copy Code { All enterprise applications follows a set of coding conventions and guidelines to maintain code in better way. Codelyzer is an open source tool to run and check whether the pre-defined coding guidelines has been followed or not. Codelyzer does only static code analysis for angular and typescript project. Codelyzer runs on top of tslint and its coding conventions are usually defined in tslint.json file. Codelyzer can be run via angular cli or npm directly. Editors like Visual Studio Code and Atom also supports codelyzer just by doing a basic settings. To set up the codelyzer in Visual Studio code, we can go to File -> Preferences -> User Settings and add the path for tslint rules. Hide Copy Code { |
|
| 9. |
What Are Event Emitters And How It Works In Angular 2? |
|
Answer» Angular 2 doesn’t have bi-directional digest cycle, unlike angular 1. In angular 2, any change occurred in the component always gets propagated from the current component to all its children in hierarchy. If the change from one component needs to be REFLECTED to any of its parent component in hierarchy, we can emit the EVENT by using Event Emitter API. In short, EventEmitter is class DEFINED in @angular/core module which can be used by components and directives to emit custom events. @output() somethingChanged = new EventEmitter(); We use somethingChanged.emit(VALUE) method to emit the event. This is usually done in setter when the value is being changed in the class. This event emit can be subscribed by any component of the module by using subscribe method. myObj.somethingChanged.subscribe(val) => this.myLocalMethod(val)); Angular 2 doesn’t have bi-directional digest cycle, unlike angular 1. In angular 2, any change occurred in the component always gets propagated from the current component to all its children in hierarchy. If the change from one component needs to be reflected to any of its parent component in hierarchy, we can emit the event by using Event Emitter api. In short, EventEmitter is class defined in @angular/core module which can be used by components and directives to emit custom events. @output() somethingChanged = new EventEmitter(); We use somethingChanged.emit(value) method to emit the event. This is usually done in setter when the value is being changed in the class. This event emit can be subscribed by any component of the module by using subscribe method. myObj.somethingChanged.subscribe(val) => this.myLocalMethod(val)); |
|
| 10. |
How Routing Works In Angular 2.? |
|
Answer» Routing is a MECHANISM which enables user to navigate between views/components. Angular 2 simplifies the routing and provide flexibility to configure and define at module LEVEL (Lazy loading). The angular application has single instance of the Router service and whenever URL changes, corresponding Route is matched from the routing configuration array. On successful match, it applies redirects and the router builds a tree of ActivatedRoute objects and contains the current state of the router. Before redirection, the router will CHECK whether new state is permitted by running guards (CanActivate). Route Guards is simply an interface method that router runs to check the route AUTHORIZATION. After guard runs, it will resolve the route data and activate the router state by INSTANTIATION the required components into <router-outlet> </router-outlet>. Routing is a mechanism which enables user to navigate between views/components. Angular 2 simplifies the routing and provide flexibility to configure and define at module level (Lazy loading). The angular application has single instance of the Router service and whenever URL changes, corresponding Route is matched from the routing configuration array. On successful match, it applies redirects and the router builds a tree of ActivatedRoute objects and contains the current state of the router. Before redirection, the router will check whether new state is permitted by running guards (CanActivate). Route Guards is simply an interface method that router runs to check the route authorization. After guard runs, it will resolve the route data and activate the router state by instantiation the required components into <router-outlet> </router-outlet>. |
|
| 11. |
What Are The Advantages Of Using Angular 2 Over Angular 1? |
|
Answer» Angular 2 is a platform not only a language:
Angular 2 is a platform not only a language: |
|
| 12. |
What Are The Security Threats Should We Be Aware Of In Angular 2 Application? |
|
Answer» Just LIKE any other client side or web application, angular 2 application should also follow some of the BASIC guidelines to mitigate the security risks. Some of them are:
Just like any other client side or web application, angular 2 application should also follow some of the basic guidelines to mitigate the security risks. Some of them are: |
|
| 13. |
How Can We Setting Up Angular 2 Application? |
Answer»
|
|
| 14. |
What Is Npm? |
|
Answer» Npm, or node package manager: is a COMMAND LINE utility that interacts with a repository of open source projects, Become the package manager for JavaScript. Using npm we can install LIBRARIES, packages, and APPLICATIONS, along with their DEPENDENCIES. Npm, or node package manager: is a command line utility that interacts with a repository of open source projects, Become the package manager for JavaScript. Using npm we can install libraries, packages, and applications, along with their dependencies. |
|
| 15. |
How Can We Setting Up Our Development Environment For Angular 2? |
|
Answer» Setting up our DEVELOPMENT environment for Angular 2 requires two basic STEPS:
Setting up our development environment for Angular 2 requires two basic steps: |
|
| 16. |
What Is The Languages That You Can Use To Build Angular2 Application? |
|
Answer» ECMAScript, or ES.
ECMAScript, or ES. |
|
| 17. |
What Is An Angular 2 Component? |
|
Answer» Each component is comprised of a TEMPLATE, which is the HTML for the user interface. ADD to that a class for the code associated with a view. The class contains the properties and methods, which PERFORM actions for the view,A component also has METADATA, which provides additional information about the component to Angular. Each component is comprised of a template, which is the HTML for the user interface. Add to that a class for the code associated with a view. The class contains the properties and methods, which perform actions for the view,A component also has metadata, which provides additional information about the component to Angular. |
|
| 18. |
We Already Use Angular 1, Why Do We Need An Angular 2? |
|
Answer» Angular 2 is built for speed :
Angular 2 is built for speed : |
|
| 19. |
What Are Differences Between Components And Directives? |
|
Answer» Components :
Directives :
Components : Directives : |
|
| 20. |
What Is Primeng? How Can It Be Used With Angular2? |
|
Answer» PrimeNG is a collection of rich UI components for Angular 2. PrimeNG is a sibling of the popular JavaServer Faces Component Suite, PrimeFaces. All WIDGETS are open source and free to use under Apache License 2.0, a COMMERCIAL FRIENDLY license. PrimeNG is developed by PrimeTek Informatics, a company with years of expertise in developing open source UI components. AngularJS makes it possible to use predefined components for development like TABLES etc. This helps developers save time and EFFORTS. Using PrimeNG developers can create awesome applications in no time PrimeNG is a collection of rich UI components for Angular 2. PrimeNG is a sibling of the popular JavaServer Faces Component Suite, PrimeFaces. All widgets are open source and free to use under Apache License 2.0, a commercial friendly license. PrimeNG is developed by PrimeTek Informatics, a company with years of expertise in developing open source UI components. AngularJS makes it possible to use predefined components for development like tables etc. This helps developers save time and efforts. Using PrimeNG developers can create awesome applications in no time |
|
| 21. |
What Is @outputs In Angular? |
|
Answer» COMPONENTS push out EVENTS using a combination of an @Output and an EventEmitter. This allows a CLEAN separation between reusable Components and application logic. Components push out events using a combination of an @Output and an EventEmitter. This allows a clean separation between reusable Components and application logic. |
|
| 22. |
What Is @inputs In Angular 2? |
|
Answer» @Input allows you to pass data into your controller and templates through HTML and defining CUSTOM PROPERTIES. This allows you to easily reuse components and have them display different values for each instance of the renderer. @Input allows you to pass data into your controller and templates through html and defining custom properties. This allows you to easily reuse components and have them display different values for each instance of the renderer. |
|
| 23. |
What Is Component In Angularjs 2 ? |
|
Answer» In ANGULAR, a Component is a special kind of directive that uses a simpler configuration which is SUITABLE for a component-based APPLICATION structure. In Angular, a Component is a special kind of directive that uses a simpler configuration which is suitable for a component-based application structure. |
|
| 24. |
What Is Traceur Compiler ? |
|
Answer» Traceur is a JavaScript.next-to-JavaScript-of-today compiler that allows you to USE features from the future today. Traceur supports ES6 as well as some experimental ES.next features. Traceur's goal is to inform the DESIGN of NEW JavaScript features which are only valuable if they ALLOW you to write better code. Traceur is a JavaScript.next-to-JavaScript-of-today compiler that allows you to use features from the future today. Traceur supports ES6 as well as some experimental ES.next features. Traceur's goal is to inform the design of new JavaScript features which are only valuable if they allow you to write better code. |
|
| 25. |
What Is @ngmodule? |
|
Answer» @NgModule is a decorator FUNCTION. A decorator function allows users to MARK something as Angular 2 thing (could be a module or component or something else) and it enables you to provide additional data that DETERMINES how this Angular 2 thing will be processed, instantiated and used at the runtime. So, WHENEVER user writes @NgModule, it tells the Angular 2 module, what’s going to be INCLUDED and used in and using this module. @NgModule is a decorator function. A decorator function allows users to mark something as Angular 2 thing (could be a module or component or something else) and it enables you to provide additional data that determines how this Angular 2 thing will be processed, instantiated and used at the runtime. So, whenever user writes @NgModule, it tells the Angular 2 module, what’s going to be included and used in and using this module. |
|
| 26. |
What Is Ecmascript ? |
|
Answer» ECMAScript is a subset of JAVASCRIPT. JavaScript is basically ECMAScript at its core but builds upon it. Languages such as ActionScript, JavaScript, JScript all use ECMAScript as its core. As a comparison, AS/JS/JScript are 3 different cars, but they all use the same engine... each of their exteriors is different though, and there have been SEVERAL modifications done to each to make it unique. ANGULAR2 supports ES6 and HIGHER versions. ECMAScript is a subset of JavaScript. JavaScript is basically ECMAScript at its core but builds upon it. Languages such as ActionScript, JavaScript, JScript all use ECMAScript as its core. As a comparison, AS/JS/JScript are 3 different cars, but they all use the same engine... each of their exteriors is different though, and there have been several modifications done to each to make it unique. Angular2 supports ES6 and higher versions. |
|
| 27. |
What Is The Need For Typescript In Angular2? |
|
Answer» Understanding the need for TypeScript file in Angular2 applications : JavaScript rules in Web development. Its the most popular language for developing web application UI. For may application developers having exposure in languages like Java and C#, creating the front end of a Web application in JavaScript is a very cumbersome process. For EXAMPLE if the user wants to create a class Employee in JavaScript. There is no class keyword in JavaScript so the code will be as follows- <html> class Employee This Customer.ts will compile to the above JavaScript code. So TypeScript provides the following advantages over JavaScript-
Understanding the need for TypeScript file in Angular2 applications : JavaScript rules in Web development. Its the most popular language for developing web application UI. For may application developers having exposure in languages like Java and C#, creating the front end of a Web application in JavaScript is a very cumbersome process. For example if the user wants to create a class Employee in JavaScript. There is no class keyword in JavaScript so the code will be as follows- <html> class Employee This Customer.ts will compile to the above JavaScript code. So TypeScript provides the following advantages over JavaScript- |
|
| 28. |
What Is Typescript ? |
|
Answer» TypeScript is a TYPED super SET of JavaScript which has been built and MAINTAINED by MICROSOFT and chosen by the AngularJS team for development. TypeScript is a typed super set of JavaScript which has been built and maintained by Microsoft and chosen by the AngularJS team for development. |
|
| 29. |
What Is The Need Of Angular2? |
|
Answer» ANGULAR 2 is not just a typical UPGRADE but a totally NEW development. The whole framework is rewritten from the ground. Angular 2 got rid of many things like $scope, controllers, DDO, jqLite, angular.module etc. It uses components for almost everything. Imagine that even the whole app is now a COMPONENT. Also it takes advantage of ES6 / TypeScript syntax. Developing Angular 2 apps in TypeScript has made it even more powerful. Apart from that, many things have EVOLVED and re-designed like the template engine and many more. Angular 2 is not just a typical upgrade but a totally new development. The whole framework is rewritten from the ground. Angular 2 got rid of many things like $scope, controllers, DDO, jqLite, angular.module etc. It uses components for almost everything. Imagine that even the whole app is now a component. Also it takes advantage of ES6 / TypeScript syntax. Developing Angular 2 apps in TypeScript has made it even more powerful. Apart from that, many things have evolved and re-designed like the template engine and many more. |
|
| 30. |
What Are The New Features Of Angular2? |
|
Answer» Angular 2 is written ENTIRELY in Typescript and meets the ECMAScript 6 specification :
Angular 2 is written entirely in Typescript and meets the ECMAScript 6 specification : |
|