Angular 7 Interview Questions and Answers

45+ TOP Angular 7 Interview Questions and Answers

Angular 7 Interview Questions
Angular 7 Interview Questions

1. In Visual Studio, which angular cli command we should use to build the angular code every time when any changes are detected?
We should use ‘ng build –watch’ command to trigger the build automatically when any changes have been detected in the angular project.

2. How can we implement Azure AD and ADFS authentication in Angular 7?
We can make use of ‘Adal service’ to implement Azure AD and ADFS authentication in Angular 7.

3. Is there any attributes available in anchor tag to change the route?
Yes, we have a attribute called ‘routerLink’ which will change the route while user clicking on that tag.

4. How can we attach a token for every HTTP request in Angular 7?
At first we have to generate a token and store it in sessionStorage object. Then with the help of interceptor service, we can attach the token in the headers for each HTTP request.

5. How to refresh/renew the token after a particular time interval?
With the help of ‘NgZone’, we can achieve this. ‘NgZone’ will run independently and it will keep a track of time from when we started the application. Once a threshold value is reached we need to call the method to generate the token again.

6. Using Angular 7, is it possible to have both angular route as well as MVC route? If yes, how can it be possible?
Yes, it is possible using ‘constraints’ configuration in ‘RegisterRoutes’ method of ‘RouteConfig’ class.

7. You have a feature of Add/Edit/Filter in a Angular application. Most of the fields are same in each of the feature. What is the best way to achieve that?
We have to use ‘Dynamic Component’ for each feature(Add/Edit/Filter) and we have to use ‘Reactive forms’. If we use ‘Reactive forms’, even if we need to add new fields in any of the components, there will be no change in template but only in ‘FormData JSON’.

8. How will you interact with the components which don’t have parent-child relationship, but you need to send data from one to another?
We can make use of behaviour subject in this case.

9. Can we achieve @Input-@Output(EventEmitter – to interact with parent/child) in Dynamic Components?
No. In this case we have to make use of variables of corresponding service.

10. Is there any way to hold the data/obj globally across all components without making use of service variables?
Yes. We can make use the package ‘ng2-simple-global’ in this case.

11. When can router.navigate([]) will not work?
When we try to navigate the invalid routes or the routes which is not configured in Routing Module, it will not work as expected.

12. How to get the current url in the address bar using Angular 7?
We can get the current url using ‘Router’ module(this.router.url).

13. How to close the visible popup on click of window other than popup?
Using ‘clickOutside’ event in the div popup will trigger the click event which is happened outside the popup. With the help of this, we can able to close/hide the popup.

14. Where will you do the application configuration changes for different environments?
We can make use of environment.ts file for this purpose.

15. Is it possible to minify the source files without any external package in Anglar 7?
Yes. It is possible to minify the source files by making some configuration changes in angular.json and package.json.
Get Angular 7 100% Practical Training

16. Using Angular 7, is it possible to have both angular route as well as MVC route? If yes, how can it be possible?
Yes, it is possible using ‘constraints’ configuration in ‘RegisterRoutes’ method of ‘RouteConfig’ class.

17. You have a feature of Add/Edit/Filter in a Angular application. Most of the fields are same in each of the feature. What is the best way to achieve that?
We have to use ‘Dynamic Component’ for each feature(Add/Edit/Filter) and we have to use ‘Reactive forms’. If we use ‘Reactive forms’, even if we need to add new fields in any of the components, there will be no change in template but only in ‘FormData JSON’.

18. How will you interact with the components which don’t have parent-child relationship, but you need to send data from one to another?
We can make use of behaviour subject in this case.

19. Can we achieve @Input-@Output(EventEmitter – to interact with parent/child) in Dynamic Components?
No. In this case we have to make use of variables of corresponding service.

20. Is there any way to hold the data/obj globally across all components without making use of service variables?
Yes. We can make use the package ‘ng2-simple-global’ in this case.

21. When can router.navigate([]) will not work?
When we try to navigate the invalid routes or the routes which is not configured in Routing Module, it will not work as expected.

22. How to get the current url in the address bar using Angular 7?
We can get the current url using ‘Router’ module(this.router.url).

23. How to close the visible popup on click of window other than popup?
Using ‘clickOutside’ event in the div popup will trigger the click event which is happened outside the popup. With the help of this, we can able to close/hide the popup.

24. Where will you do the application configuration changes for different environments?
We can make use of environment.ts file for this purpose.

Q25) Is it possible to minify the source files without any external package in Anglar 7?
Yes. It is possible to minify the source files by making some configuration changes in angular.json and package.json.

Q26) Can we able to call index1.html in our application? If so then will be able to call it?
Yes we can create index1.html in aour application.
We can call index1.html page by change setting of “index” in angulr-cli.json file.

Q27) Can we able to use one component without sharing its code?
If we upload our code in some repositery then we can able to use the component by downloading it .

Q28) What is internal functionality of *ngFor?
Internally Angular transforms asterisk(*) syntax into <ng-template> and apply looping to it.

Q29) What is pure and impure pipe?
A pure pipe only executed only when a pure change to the input value is detected
When any impure changes to the input value is detected then impure pipes executes.

Q30) What is the purpose of main.ts file?
main.ts file is the main entry point of our application. Compiles the application boostraped it to run in the browser.

Q31) What are pollyfills?
We provide pollyfill script for browser support.

Q32) Difference between reactive and template browser.
Template forms depends totally on the template so if we want to make any complex/big forms it will make template heavy
Reactive forms depends more on the .ts file and not on the template we can use reactive forms to build dynamic forms , we use reactive forms to build complex forms.

Q33) What is dependency Injection in angular?
Dependency Injection is a process where the class asks for dependencies from external resources rather than creating them itself.

Q34) What are observables?
Observables provide support for passing information between observables and subscribers.

Q35) What is aot compilation?
The AOT compilation converts HTML and typescript code into javascript code in the build phase before the browser download and runs that code. This makes the rendering faster in the browser.
Get Angular 7 Training with Real time Live Projects

Q36) Who we pass data between components which dont have any parent child relation?
We can use angular service i.e. Behavioural Subject to serves this purpose.

Q37) What Is Parameterizing Pipe?
The Date is – {{ Date | date:”MM/dd/yy” }} </h2>
<!– Output – The Date is – 10/03/1984 –>

Q38) What Is Chaining Pipe?
This chaining operation will be chained using the pipe (I).
In the following example, to display the birthday in the upper case- will need to use the inbuilt date-pipe and upper-case-pipe. example –
{{ birthday | date | uppercase}}.

Q39) What is AOT Compilation?
AOT refers to Ahead-of-time compilation. In Angular, it means that the code you write for your application is compiled at build time before the application is run in a browser.

40. What ide is suitable to develop and run Angular 7 apps?
We can download visual studio code from https://code.visualstudio.com

41. What is the command in Angular 7 to start server?
ng serve

42. What is command for creating component in Angular 7?
ng generate component component_name

43. What are directives in Angular 7?
Component Directives
Structural Directives
Attribute Directives

44. What are type of forms in Angular 7?
Reactive forms
Template-driven forms

45. What is Angular 7?
It is written in Typescript which is JavaScript based framework .It supports MVC
framework i.e Model,View and Controller.It is developed by Google.

Frequently Asked Angular 7 Interview Questions