This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 101. |
What is routing in angular 2? |
|
Answer» Routing is what lets in you to create Single Page APPLICATIONS. AngularJS routes ALLOW you to create distinct URLS for ONE of a kind content material in your application. It helps in redirecting users to exceptional pages based totally on the alternative they pick out on the main page. AngularJS routes ENABLE one to show more than one content depending on which route is chosen. A route is unique in the URL after the # sign. Related Article: How to Overcome the Fear of Angular 2 Interview Questions |
|
| 102. |
What is the factory method in Angular 2? |
|
Answer» As services are reusable singleton objects in AngularJS which is USED to organize and share CODES across the APPLICATION, they can be injected into filters, controllers, and directives. Angular 2 offers three ways to create a service; factory, service, and provider. The factory function allows developers to include some logic before creating the object and RETURNS the created object. The syntax for factory function is as follows. app.factory('serviceName',function(){ return serviceObj;}) |
|
| 103. |
What is deep linking in Angular 2? |
|
Answer» In Angular 2, deep linking is a process of the URL that will take to users to a SPECIFIC page or content DIRECTLY without crossing the application from the homepage. The deep linking process helps with website or application indexing so that search engines can EASILY crawl these links. |
|
| 104. |
What happens when the page containing Angular based application loads? |
|
Answer» When a page containing Angular BASED application loads, these below-mentioned scenarios will be completed. |
|
| 105. |
What is Angular 2 and also explain its components? |
|
Answer» Angular 2 is the UPGRADED and evolved version of AngularJS, a JavaScript FRAMEWORK that was INVENTED by Google. Angular 2 is used for building single-page web or mobile applications. Components are essential elements of Angular 2 apps, and an application can have a number of components. In Angular 2, components PERFORM all the tasks that were done by scopes, controllers and directives, such as creating or adding Data, logic, and CUSTOM elements. In Angular 2 a component consists of the following:
|
|
| 106. |
What are lifecycle hooks and why it is important? |
|
Answer» In ANGULAR, lifecycle hooks are FUNCTIONS which will be called at specific POINTS of a component lifecycle in Angular applications. They are HIGHLY crucial for a component architecture based application. |
|
| 107. |
What is the use of polyfills.ts file in Angular 2? |
|
Answer» In Angular 2, the polyfills.ts file is used to MAKE user application compatible for VARIOUS browsers. The code we write in Angular 2 is mostly in ES6, which is not compatible with FIREFOX or IE, and requires few environmental setups before they wither get VIEWED or used in browsers. Angular offers Polyfills.ts file to help users with the required setup. |
|
| 108. |
What is the difference between annotation and decorator in Angular 2? |
||||||||||
Answer»
|
|||||||||||
| 109. |
How to create a singleton service in Angular 2? |
|
Answer» Here is the steps to CREATE a singleton service-
|
|
| 110. |
How you can load external css style? |
|
Answer» To ALLOW a load of external CSS styles in Angular 2 to affect component contents, we have to change view ENCAPSULATION which presents styles to COMPONENTS referring “bleed into”. @Component({ |
|
| 111. |
What is shadow dom and how it is helping to perform better in angular 2? |
|
Answer» Shadow DOM is an integral PART of Web Components standard while enables users for style ENCAPSULATION and DOM tree. It helps users to hide DOM logic behind other elements. With the addition to it, we can also APPLY scoped styles to elements WITHOUT showcasing them to the outer world. |
|
| 112. |
How to define custom typings to avoid editor warnings? |
|
Answer» To avoid editor warning whilst defining CUSTOMIZED typings, we have to prolong the KIND DEFINITION for an external library as a accurate practice. Without ALTERING any node_modules or current typings FOLDER, we have to create a new folder named “custom_typings" and put all our customized kind definitions there. |
|
| 113. |
What is tree shaking? |
|
Answer» The Tree SHAKING is a concept of dead code elimination from PROJECTS. The code PRESENT in your project but neither referenced nor USED will be dropped here. It will eliminate the unused modules during the BUILD process, making user application lightweight. |
|
| 114. |
What is the purpose of tsconfig.json in Angularjs? |
|
Answer» It allows us to specify the root level files. The compiler options required to compile a TypeScript project. It DETERMINES that the said DIRECTORY is the TypeScript project root. Here is a JSON file describing to define a tsconfig.json file containing different parameters of the compilerOptions property: { "compilerOptions": {
|
|
| 115. |
Is angular 2 Object Oriented? |
|
Answer» Yes, Angular 2 is a TRUE object-oriented development framework. |
|
| 116. |
How would you optimize the application for better performance in angular 2? |
|
Answer» To optimize an application for optimal performance in Angular 2, we have to follow the below-mentioned steps.
|
|
| 117. |
What is primeng and how can it be used with angular2? |
|
Answer» PrimeNG is a rich UI component collection DEDICATED to ANGULAR. Widgets present here are completely open-source and FREE to use. It’s simple, lightweight yet powerful and optimized for RESPONSIVE cross-browser touch. |
|
| 118. |
What is SPA in Angular 2? |
|
Answer» SPA in Angular 2 stands for Single Page Applications. This is a TYPE of web-application which fits into literally one page. All your code (JavaScript, HTML, CSS) is CALLED using a single page load at multiple points by adding new data parallelly from the backend. Navigation between pages PERFORMED can be DONE without refreshing. |
|
| 119. |
What is Flex layout in Angular 2? |
|
Answer» Flex Layout in Angular 2 is a component engine that allows you to CREATE Flexbox page layouts with a fixed SET of directives to use in designing templates. The Flex-Layout has made styling EASY and user-friendly by having a TypeScript based Library, thus eliminating the need for external stylesheets/CSS Styling. In addition to this, it can be used along with Material Design for Design components and also providing intuitive BREAKPOINTS while development to AID in designing responsive layouts. |
|
| 120. |
How to display the error message from backend in angular2? |
|
Answer» To DISPLAY error message in Angular 2 from BACKEND, we have to set the error message equal to an angular variable, and then check whether that variable exists to CONFORM whether to display it or not. <div *NGIF="errors" class="alert alert-danger">
|
|
| 121. |
What is @input and @output in Angular 2? |
|
Answer» Both @input and @output are decorators. The decorator @Input is used to bind a property WITHIN ONE child COMPONENT to receive value from the parent component, WHEREAS we use the @output decorator to bind the property of a component to send data from child component to parent component or calling component. |
|
| 122. |
What is hidden property in Angular 2? |
|
Answer» In Angular 2, hidden property or [hidden] is a special case binding USED to hide property. It can be compared CLOSE to ng-show and ng-hide, but more powerful to bind any property types of elements. Example <div [hidden]="!active"> Hello, this is an active AREA! </div> |
|
| 123. |
What are filters in Angular 2? |
|
Answer» A filter is a NECESSARY phase of Angular 2 as well as Angular 4. It is basically used to filter an object from a crew of items, which are there in an array or an object array. It SELECTS a subset of the objects from an array and returns it as a new array and displayed on UI. Filters can be used with an expression USING pipe | sign. {{expression | filterName:parameter }} Angular 2 includes various filters to layout records of special fact types. Also Read: How to crack the interview in the first ATTEMPT |
|
| 124. |
What is Router-link directive in Angular 2? |
|
Answer» The router-link derivatives enable the navigation from any specific view to the other. It works immediately as a USER is performing application tasks. The link can directly arise from browser and navigation is done on the basis of user action like the click of an anchor TAG. The router link directive gives control to the router for anchor tag elements. It also binds a clickable HTML to the route to enable the navigation. The routerlink directive can easily be bound to an array, E.g. <a [routerlink] = "[ '/ heroes']" >Heroes</a> 23. What is the configuration required for caching of static resources like IMAGES, css and js in Angular 2?During Development MODE, caching for static resources can be done through the Design of Tools. If you want to cache on the production stage, you need to CHECK and update the Server-End Settings accordingly. Note: These are basic angular 2 interview questions that are asked for a position as SDE in Angular Development. |
|
| 125. |
How do you check if angular CLI is installed? |
|
Answer» To CHECK this, you need to make SURE that node is INSTALLED and then check if angular CLI is installed.
|
|
| 126. |
What are the advantages & limitation of AOT compilation? |
|
Answer» Advantages-
|
|
| 127. |
What is AOT compilation? |
|
Answer» The AOT COMPILATION converts Angular HTML and TypeScript codes into JavaScript code at some stage in the construct section earlier than the browser can down load and RUN the code. Here are benefits of compiling with AOT:
|
|
| 128. |
What are the difference between @injectable() vs. @inject() in angular 2? |
|||||||||
Answer»
|
||||||||||
| 129. |
What is CLI in Angular 2? |
|
Answer» It is a command-line interface which is USED to build angular apps. We can construct & START a project very QUICKLY with the help of CLI. You can download CLI from its official website HTTPS://cli.angular.io The command for INSTALL Angular CLInpm install –g angular-cli Also Read: Front end Developer Interview Questions |
|
| 130. |
Explain the steps for creating a services in Angular 2? |
|
Answer» Here are the steps:
Here is the SYNTAX: import { Injectable } from '@angular/core'; |
|
| 131. |
What are angular 2 hooks? |
|
Answer» In Angular apps, hooks are FUNCTIONS that are called on particular stages of a component’s life. Hooks are ESSENTIAL if your APP is based on the component ARCHITECTURE. Example for hooks is $onInit, $onChanges, etc. which are properties pre-defined by Angular and can be exposed on component controllers. |
|
| 132. |
What are the advantages of Angular 2 over Angular? |
||||||||||||||||||
|
Answer» Advantages of Angular 2 over Angular are given below-
|
|||||||||||||||||||
| 133. |
How do you declare a global variable in Angular 2? |
|
Answer» The SIMPLEST WAY is to put the variables in a file and export them. In order to USE global variables, you can use an import statement. 'use STRICT'; export const name='bestinterviewquestion.com'; After that, we can export this file where we want to use these global variables value. |
|
| 134. |
What is lazy loading in angular 2? |
|
Answer» Lazy loading allows developers to load different code pieces on demand. For instance, if you have a retail APPLICATION that has different departments like garments, groceries, electronics, etc. If you load all the sections, in the beginning, your application will be slow. This is when you need lazy loading. It helps the application load faster because it LOADS only PARTS that the USER wants to see. This interview questions on angular 2 are always a level up and thus a little tough to crack. Related Article: What is lazy loading in angular 2 |
|
| 135. |
How to enable lazy loading in Angularjs? |
|
Answer» With lazy LOADING, JS components can be LOADED asynchronously on activation on a specific route.
resolve: { |
|
| 136. |
What is pipes in Angular 2? |
|
Answer» In all ANGULAR version from 2 onwards, there is a common feature called Pipes. This feature helps developers create custom pipes. Pipes are used to write display-value transformations that developers can declare in their HTML. A pipe INPUTS data and TRANSFORMS it into the REQUIRED output. Pipes in Angular2There are some pipe provided by angularjs are given below-
|
|
| 137. |
What is dependency injection in Angular? |
|
Answer» Angular has a robust DI FRAMEWORK that gives declared DEPENDENCIES to a class upon instantiation. To inject a SERVICE, you must first create and register the injectable service. Related Article: Angular 8 interview questions and AnswersExampleimport { Injectable } from '@angular/core'; |
|
| 138. |
What is RouterOutlet in Angular 2? |
|
Answer» In ANGULAR 2, the RouterOutlet is a directive PRESENT in the ROUTER library to be used as a component. It marks the spot in a template for the router to DISPLAY the components for that outlet. Every outlet can have its unique name, which is determined by the optional name ATTRIBUTE. The name once set cannot be changed dynamically. If no value has been set, the default value is "primary". <router-outlet></router-outlet> <router-outlet name="left"></router-outlet> <router-outlet name="right"></router-outlet> The router outlet emits an activate event during the instantiation of a new component. When the component is destroyed, it is deactivated. <router-outlet (activate)='onActivate($event)' (deactivate)='onDeactivate($event)'></router-outlet> |
|
| 139. |
What is directive in Angular? |
|
Answer» DIRECTIVES are the extended HTML attributes and they are ALSO the most IMPORTANT FEATURES of Angular applications. They introduce syntax or markup. There are 3 kinds of directives-
|
|
| 140. |
How do you create a custom pipe in Angular? |
|
Answer» In Angular 2, you can create CUSTOM PIPES. The simplest way is as follows. import { Pipe, PipeTransform } from '@angular/core'; |
|
| 141. |
What is string interpolation Angular? |
|
Answer» String Interpolation is a SPECIAL syntax in Angular 2 which is a more efficient alternative to property binding. It is used to display dynamic data on an HTML TEMPLATE while facilitating you to make changes on the component.ts FILE and fetch data for the HTML template. Below is an example of a String Interpolation syntax. It should be between double curly braces {{ }} and hence also CALLED a moustache syntax: Exampleclass AppComponent |
|
| 142. |
What is event emitters in Angular 2 and how it works? |
|
Answer» Any change that occurs in the component gets propagated from the existing component to its children. If this change NEEDS to be reflected its parent component, you can use USING Event Emitter api to emit the event. EventEmitter is class in @angular/core module that is used by DIRECTIVES and components to emit events. @output() somethingChanged = new EventEmitter(); You can use somethingChanged.emit(VALUE) to emit any event. You can do this in setter when the value is changed in the class. |
|
| 143. |
What is Traceur compiler in Angular 2? |
|
Answer» Traceur compiler takes classes, GENERATORS, and other FEATURES from ECMAScript edition 6 (ES6) and compiles it into JavaScript ES5 that runs on the browser. This means developers can use the code from a FUTURE version that has more features and encourages design patterns. |
|
| 144. |
What is the difference between directive and component in Angular 2? |
|||||||||||||||
Answer»
|
||||||||||||||||
| 145. |
What is the difference between component and directive in Angular 6? |
||||||||||||||
Answer»
|
|||||||||||||||
| 146. |
What is a dl token in Angular 6? |
|
Answer» In Angular 6, a DI TOKEN means a Dependency Injection Token. It is basically a lookup token associated with a dependency provider, to be USED in the Dependency Injection SYSTEM. |
|
| 147. |
What are the case types in Angular 6? |
|
Answer» There are three CASE types in ANGULAR 6:
|
|
| 148. |
What is HostListener in Angular? |
|
Answer» HostListener in Angular 6 is basically a decorator which declares a DOM EVENT to LISTEN for and also provide a handler method to run if and when that specific event OCCURS. Host Listener is a SET of arguments that is USED to pass the handler method when an event occurs. |
|
| 149. |
What is style function in Angular 6? |
|
Answer» In Angular 6, a style FUNCTION is USED to declare a key or VALUABLE object which contains CSS properties and or styles that shall be used in an animation state or sequence. It can be used within styling data for calls to ANIMATE and keyframes. |
|
| 150. |
What is Linting in Angular? |
|
Answer» In Angular 6, LINTING is a tool that is used to check the TYPESCRIPT code for programmatic and styling ERRORS. A JSON FILE is a CONFIGURATION for linting and this file contains all the default guidelines for linting. |
|