Angular Basic Questions

Here are some basics questions about Angular Framework for beginner.

What does the mean of ‘e2e’ in Angular?

‘e2e’ is a folder present in the Angular application where testing is performed. It uses to end-to-end black box testing. ng e2e CLI command uses the Protractor library for automated testing.

What is the purpose of CLI ‘ng serve’?

‘ng serve’ opens up the Angular application on the localhost. It builds the files in memory. This CLI runs the Webpack to bundling the files and also starts the Webpack dev server.

What is the purpose of ‘ng build’ in Angular?

‘ng build’ CLI command build or bundle the project into output folder ‘dist’. It uses for deployment of the application.

What is the role of ‘component’?

The component is the combination of View, Styles, and Script. It is the basic unit of Angular and generates by ‘ng generate componentName’ CLI. We use Component as a directive in HTML.

What does the mean of ‘service’ in Angular?

The main function of a service is to organize and share business logic, models, or data and functions with different components of an Angular app by dependency injection. Service is just a javascript function and can be created through CLI ‘ng generate service [name]’.

What is the purpose of AOT?

The Ahead-of-Time (AOT) is the latest compiler version for supporting the fast browser rendering.

What is ‘app.module.ts’?

It is the module file where it contains the modules and components that we are going to be using.

Why use ‘pollyfills.js’?

Polyfills uses to compatible with different browsers.

What is the purpose angular.json?

CLI projects will now use angular.json instead of .angular-cli.json for build and project configuration.

What is a vendor.js?

It contains the all third party libraries.

What is the purpose of OnInit and OnChanges?

Both are Angular lifecycle hook. OnInit invokes (only one time) when the component has been initialized. It can be implemented by component, pipe, directives. OnChanges called whenever a data-bound property of directive changes.

What is the purpose of ‘ng build –base-href /myapp/’?

If we have our application in a subfolder then we should run ‘ng build –base-href /myapp/’ CLI.

What does the mean of –routing?

It is Angular CLI option to create a app-routing.module.ts file in the ‘src/appfolder’.

What is the RxJS?

Rxjs is a set of libraries to compose asynchronous and event-based programs using observable collections and Array#extras style composition in JavaScript.

What is the main function of Hammerjs?

Hammerjs is a library which supports the touch events.

How to use JQuery or JQuery plugins in the Angular component?

First, you need to add JQuery library path on the index.html header.

Second, you need to initialize the ‘$’ where you want in .ts file.

Now, you can use jquery like:

What is the Protector in angular?

Protector is the de facto end to end testing framework for Angular.”Protractor runs tests against your application running in a real browser, interacting with it as a user would.”

What does the mean of CDK in angular?

A Component Dev Kit for Angular. We can use it by adding:

import { DataSource } from ‘@angular/cdk/collections’;

Why use ‘{{}}’ in Angular?

It’s a Angular syntax to use written the expression. Like {{ 1+1 }}

Please, take a look at my article about ReactJS Basics