Frequently Asked Interview Questions And Answers For Angular Programming Freshers

50,000+ Students Trained, 19+ Our Offices, 18+ Courses Offered,

Job Guarantee + Job Satisfaction, 2000+ Company Tie Ups For Placements

Angular Interview Question

Most Important Question:-

 
  1. 1. What’s new in Angular 5?
Ans. Certain tools are optimized in the new version of Angular, let us see what the tools are:
  • ● Angular 5 supports Typescript version 2.4
  • ● Angular 5 supports RxJS 5.5 which has new features like Pipeable Operators
  • ● A build tool to make the js bundles (files) lighter
  • ● Ahead of Time (AOT) is updated to be on by default
  • ● Events like ActivationStart and ActivationEnd are introduced in Router
 
  1. 2. Name the building blocks of Angular.
Ans. The Angular application is made using the following:
  • • Modules
  • • Component
  • • Template
  • • Directives
  • • Data Binding
  • • Services
  • • Dependency Injection
  • • Routing
 
  1. 3. What is Transpiling in Angular?
Ans.  Transpiling is the process of converting the typescript into javascript (using Traceur, a JS compiler). Though typescript is used to write code in the Angular applications, the code is internally transpiled into javascript.  
  1. 4. Which of the Angular life cycle component execution happens when a data-bound input value updates?
Ans. ngOnChanges is the life cycle hook that gets executed whenever a change happens to the data that was bound to an input.  
  1. 5. Differentiate between Components and Directives in Angular 5.
Ans. Components break up the application into smaller parts; whereas, Directives add behavior to an existing DOM element.  
  1. 6. What is the use of @Input and @Output?
Ans.  When it comes to the communication of Angular Components, which are in Parent-Child Relationship; we use @Input in Child Component when we are passing data from Parent to Child Component and @Output is used in Child Component to receive an event from Child to Parent Component.  
  1. 7. What is ng-content Directive?
Ans.  The HTML elements like p (paragraph) or h1 (heading) have some content between the tags. For example,

this is a paragraph

and

this is a heading

. Now, similar to this, what if we want to have some custom text or content between the angular tags like some tax-related content This will not work the way it worked for HTML elements. Now, in such cases, the tag directive is used.  
  1. 8. What does a router.navigate do?
Ans. When we want to route to a component we use router.navigate. Syntax: this.router.navigate([‘/component_name’]);  
  1. 9. What is ViewEncapsulation?
Ans.  ViewEncapsulation decides whether the styles defined in a component can affect the entire application or not. There are three ways to do this in Angular:
  • Emulated: styles from other HTML spread to the component.
  • Native: styles from other HTML do not spread to the component.
  • None: styles defined in a component are visible to all components.
 
  1. 10. What are Services in Angular and what command is used to create a service?
Ans.  Services help us in not repeating the code. With the creation of services, we can use the same code from different components. Here is the command to create a service in angular, ng g service User (a UserService is created when this command is used).  
  1. 11. What is Dependency Injection in Angular 4?
Ans.  When a component is dependent on another component the dependency is injected/provided during runtime.  
  1. 12. What is Routing in Angular 5?
Ans.  Routing helps a user in navigating to different pages using links.  
  1. 13. How to handle Events in Angular 5?
Ans.  Any activity (button click, mouse click, mouse hover, mouse move, etc) of a user on a frontend/web screen is termed as an event. Such events are passed from the view (.HTML) page to a typescript component (.ts).  
  1. 14. What is a RouterOutlet?
Ans.  RouterOutlet is a substitution for templates rendering the components. In other words, it represents or renders the components on a template at a particular location.  
  1. 15. Explain the usage of {{}}?
Ans.  The set of brackets {{}} when used with an HTML tag, represent data from a component. For example, on a HTML page which has

{{variableName}}

, here the ‘variableName’ is actually typescript (component) data representing its value on the template; i.e., HTML. This entire concept is called String Interpolation.  
  1. 16. In how many ways the Data Binding can be done?
Ans.  Data Binding happens between the HTML (template) and typescript (component). Data binding can be done in 3 ways: (i) Property Binding (ii) Event Binding (iii) Two-Way Data Binding.  
  1. 17. What is the sequence of Angular Lifecycle Hooks?
Ans.  OnChange() – OnInit() – DoCheck() – AfterContentInit() – AfterContentChecked() – AfterViewInit() – AfterViewChecked() – OnDestroy().  
  1. 18. What is the purpose of using package.json in the angular project?
Ans.  With the existence of package.json, it will be easy to manage the dependencies of the project. If we are using typescript in the angular project then we can mention the typescript package and version of typescript in package.json.  
  1. 19. How is SPA (Single Page Application) technology different from the traditional web technology?
Ans.  In traditional web technology, the client requests for a web page (HTML/JSP/asp) and the server sends the resource (or HTML page), and the client again requests for another page and the server responds with another resource. The problem here is a lot of time is consumed in the requesting/responding or due to a lot of reloading. Whereas, in the SPA technology, we maintain only one page (index.HTML) even though the URL keeps on changing.  
  1. 20. What is Component in Angular Terminology?
Ans.  A web page in Angular has many components involved in it. A Component is basically a block in which the data can be displayed on HTML using some logic usually written in typescript.  
  1. 21. What are ngModel and how do we represent it?
Ans.  ngModel is a directive which can be applied on a text field. This a two-way data binding. ngModel is represented by [()]  
  1. 22. What does a Subscribe method do in Angular 4?
Ans.  It is a method which is subscribed to an observable. Whenever the subscribe method is called, an independent execution of the observable happens.  
  1. 23. Differentiate between Observables and Promises.
Ans.  Observables are lazy, which means nothing happens until a subscription is made. Whereas Promises are eager; which means as soon as a promise is created, the execution takes place. Observable is a stream in which passing of zero or more events is possible and the callback is called for each event. Whereas, promise handles a single event.  
  1. 24. What is an AsyncPipe in Angular?
Ans.  When an observable or promise returns something, we use a temporary property to hold the content. Later, we bind the same content to the template. With the usage of AsyncPipe, the promise or observable can be directly used in a template and a temporary property is not required.  
  1. 25. Explain Authentication and Authorization.
Ans.  
  • Authentication: The user login credentials are passed to an authenticate API (on the server). On the server side validation of the credentials happens and a JSON Web Token (JWT) is returned. JWT is a JSON object that has some information or attributes about the current user. Once the JWT is given to the client, the client or the user will be identified with that JWT.
  • Authorization: After logging in successfully, the authenticated or genuine user does not have access to everything. The user is not authorized to access someone else’s data, he/she is authorized to access some data.
 
  1. 26. What is AOT Compilation?
Ans.  TEvery angular application gets compiled internally. The angular compiler takes javascript code, compiles it and produces javascript code again. Ahead-of-Time Compilation does not happen every time or for every user, as is the case with Just-In-Time (JIT) Compilation.  
  1. 27. What is Redux?
Ans. It is a library which helps us maintain the state of the application. Redux is not required in applications that are simple with the simple data flow, it is used in Single Page Applications that have complex data flow.  
  1. 28. What are Pipes?
Ans. This feature is used to change the output on the template; something like changing the string into uppercase and displaying it on the template. It can also change Date format accordingly.  
  1. 29. Differentiate between ng-Class and ng-Style.
Ans.  In ng-Class, loading of CSS class is possible; whereas, in ng-Style we can set the CSS style.  
  1. 30. Why Typescript with Angular?
Ans.  Typescript is a superset of Javascript. Earlier, Javascript was the only client side language supported by all browsers. But, the problem with Javascript is, it is not a pure Object Oriented Programming Language. The code written in JS without following patterns like Prototype Pattern, becomes messy and finally leading to difficulties in maintainability and reusability. Instead of learning concepts (like patterns) to maintain code, programmers prefer to maintain the code in a OOP approach and is made avilable with a programming language like Typescript was thus developed by Microsoft in a way that it can work as Javascript and also offer what javascript cannot ie;
  • ● pure OOPS as Typescript offers concepts like Generics, Interfaces and Types (a Static Typed Language) which makes it is easier to catch incorrect data types passing to variables.
  • ● TS provides flexibility to programmers experienced in java, .net as it offers encapsulation through classes and interfaces.
  • ● JS version ES5 offers features like Constructor Function, Dynamic Types, Prototypes. The next version of Javascript ie ES6 introduced new feature like Class keyword but not supported by many browsers.
  • ● TS offers Arrow Functions (=>) which is an ES6 feature not supported by many browsers directly but when used in TS, gets compiled into JS ES5 and runs in any browser.
  • ● TS is not the only alternative to JS, we have CoffeeScript, Dart(Google).
  • ● Finally, it is like, TS makes life easier when compared to JS.

Tips & Tricks

Latest Blog

Which country is better for Indian Students for Study Abroad?17th November, 2018

Canada is among the top destinations for students who choose to study abroad. Students prefer Canada

How to migrate to Canada?17th November, 2018

If you have considered moving to Canada, either you already are on the path to apply for a PR throug

Study Abroad with Minimum finance17th November, 2018

For many Indian students aspiring for high-quality education abroad, scholarships become a great h

How to Become a Good Designer?8th October, 2018

Graphic, Web, Animation, VFX, UI, UX There are plethora of options for a designer to make an amaz

Is Digital Marketing a Right Career For You?2nd October, 2018

Digital Marketing is an industry in itself that is growing rapidly since its inception. And since th

Our Events

Gyanmanjari Institute Of Technology Industrial Visits on 30th June 2018

Gyanmanjari Institute Of Technology Industrial Visits on 30th June at TOPS Technologies TOPS Techno

Android, Laravel, Python, Java and iOS Workshop at TOPS Technology

Android, Laravel, Python, Java and iOS Workshop at TOPS Technology We are happy to share that once

Project Documentation Workshop at TOPS Technologies

Project Documentation Workshop TOPS Technologies have organized “Project documentation” worksho

Final Year Project Documentation Workshop

Final Year Project Documentation Workshop Project Documentation, Project Definition, project Submis

Industrial Visit in the month of March and April at TOPS Technologies

Industrial Visits in the month of March and April at TOPS Technologies TOPS Technologies always bel