Friday, 5 March 2021

Angular Interview Question Part I

                                                        


1.What is Angular CLI?

-> Angular CLI is a command Line Interface that is used to initialize, develop, configure and maintain angular applications from a command shell. To install angular cli we use following command:

                npm install -g @angular/cli


2.Difference between npm install and npm install -g?

-> Simply, both npm install and npm install -g  are used to install all module required for the project but the difference between these command is  the actual location where they install.

 example: when we install angular cli using command npm install @angular/cli (i.e. without -g), the module is installed on the local directory under the node_modules. But when we install angular cli using command npm install -g @angular/cli (i.e. with -g or --global), the module is installed globally in the hard-disk.

 Generally it is preferred to use npm install -g command because it can be used by more than one project development process in the device.


3.What does ng serve command do?

-> ng serve command builds and serve applications and launches the application on the local server with port no. 4200. It rebuilds the application when some changes occur in the project.


4.How ng serve differs from ng build?

-> ng serve and ng build works in similar way but can be used for different purpose.

  ng serve command build watches and serves the angular application in-memory and launches in localhost:4200. It runs the application on the web server without saving the artifacts to any external folder.

 ng build command build the deployable file which is stored in the external memory such as hard-disk. It saves the file under the dist folder on the project root directory.


5.What is the purpose of ng build --prod flag?

-> ng build --prod flag is generally used for optimization. It helps to optimize the code by removing whitespace, comments that makes it occupy less space in the storage disk and then makes it easy to deploy.


6. What is the importance of src and e2e folder?

-> Project structure of angular is created by using the command ng new <project-name>.


src is a folder that contains main source code related to your angular application.

An e2e folder at top level of folder structure contains source files for the end-to-end test that correspond to the root-level application. 


Video tutorial for angular:



No comments:

Post a Comment