Angular Flashcards

1
Q

What is Single Page Web Application?

A

An SPA (Single-page application) is a web app implementation that loads only a single web document, and then updates the body content of that single document via JavaScript APIs

This therefore allows users to use websites without loading whole new pages from the server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the basic building blocks of Angular Framework?

A

Angular Components . These are organized into NgModules.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is NgModule in Angular?

A

An NgModule is a class marked by the @NgModule decorator with a metadata object that describes how that particular part of the application fits together with the other parts.

NgModules collect related code into functional sets;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do components work in angular ?

A

Components define views, which are sets of screen elements that Angular can choose among and modify according to your program logic and data
Components use services, which provide specific functionality not directly related to views. Service providers can be injected into components as dependencies, making your code modular, reusable, and efficient.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are decorators in Angular ?

A

Modules, components, and services are classes that use decorators.
These decorators mark their type and provide metadata that tells Angular how to use them.

The metadata for a component class associates it with a template that defines a view.

The metadata for a service class provides the information Angular needs to make it available to components through dependency injection (DI)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why Organizing the code into distinct functional modules is necessary?

A

Organizing your code into distinct functional modules helps in managing development of complex applications, and in designing for reusability.

In addition, this technique lets you take advantage of lazy-loading —that is, loading modules on demand— to minimize the amount of code that needs to be loaded at startup.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Can Modules be loaded asynchronously?

A

Modules can be loaded eagerly when the application starts or lazy loaded asynchronously by the router.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a Feature Module?

A

A feature module collaborates with the root module and with other modules through the services it provides and the components, directives, and pipes that it shares.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the declarations array in NgModule used for?

A

The declarations array is available for you to add declarables, which are components, directives, and pipes that belong exclusively to this particular module.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a Javascript module?

A

A JavaScript module is an individual file with JavaScript code, usually containing a class or a library of functions for a specific purpose within your application. JavaScript modules let you spread your work across multiple files.

You can Import or Export modules using ‘import’ or ‘export’ keyword.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is root module?

A

An application always has at least a root module (App Module)that enables bootstrapping and typically has many more feature modules.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are declarations in NgModule?

A

declarations: The components, directives, and pipes that belong to the NgModule. A new application project’s root NgModule has only one component, called AppComponent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are imports in NgModule?

A

imports: Other NgModules you are using, so that you can use their declarables. The newly generated root NgModule imports BrowserModule in order to use browser-specific services such as DOM rendering, sanitization, and location.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are providers in NgModule?

A

providers: Providers of services that components in other NgModules can use. There are no providers in a newly generated root NgModule.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is bootstrap in NgModule?

A

bootstrap: The component that Angular creates and inserts into the index.html host web page, thereby bootstrapping the application. This component, AppComponent, appears in both the declarations and the bootstrap arrays.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are directives in Angular?

A

Structural , Attribute and Components

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Can we create Custom Structural and Custom Attribute directives ?

A

We can create custom attribute directive like highlighting the selected element by setting the background color and custom structural directive like notIf which works exact opposite of ngIf

18
Q

What is BrowserModule in Angular?

A

Should be imported to run your application in a browser.

19
Q

What is CommonModule in Angular?

A

Should be used if ‘ngIf’ , ‘ngFor’ are used

20
Q

What is FormsModule in Angular ?

A

To build template driven forms (includes NgModel).

21
Q

What is ReactiveFormsModule in Angular

A

To build reactive forms.

22
Q

What is RouterModule in Angular?

A

To use RouterLink, .forRoot(), and .forChild().

23
Q

What is HttpClientModule in Angular?

A

To communicate with a server using the HTTP protocol.

24
Q

Will Express accept CORS -cross origin requests (Request from other domain) ?

A

No , By default express doesn’t allow CORS. By using middleware CORS it is possible .

25
Q

What is a stream?

A

A stream is a sequence of values in time

26
Q

Are streams and observables same?

A

No

27
Q

What is an Operator in Rxjs?

A

An operator is a function that takes an Observable, and returns another Observable.

28
Q

What is Functional Reactive programming?

A

Functional Reactive Programming (FRP) is a paradigm for software development that says that entire programs can be built uniquely around the notion of streams. Not only frontend programs, but any program in general.

29
Q

Does programs built in Functional Reactive programming have state?

A

the application does have a state, but that state it’s typically stored on certain streams or in the DOM, not on the application code itself.

30
Q

What does cold observable mean?

A

observable is said to be cold because it does not generate new values if no subscriptions exist.

31
Q

Are observables shared between subscribers?

A

No, each subscriber gets their own seperate processing chain

32
Q

How does Angular use Observables?

A
  1. As an internal implementation mechanism, to implement some of its core logic like EventEmitter
  2. As part of its public API, namely in Forms and the HTTP module
33
Q

What does Map Operator do?

A

The map operator simply takes an Observable and adds a transforming function that processes the output of the stream.
For Example,
const obs = interval(500)
.pipe(
take(5),
map(i => 2 * i )
);

34
Q

What does Scan Operator do?

A

To know what is the state of the observable after each element is reduced and react to that instead of only to the final result of the reduction operation.

35
Q

What does Share Operator do?

A

The share operator allows us to share a single subscription of a processing chain with other subscribers.

36
Q

What does Concat Operator do?

A

The concat operator combines multiple observables and do consecutive HTTP requests

37
Q

What does retry operator do?

A

It sends the request(does retry) until it receives the response from the URL

38
Q

What does retryWhen do?

A

It sends the request(does retry) until it receives the response from the URL based on the condition that is specified inside it.

39
Q

Can we use Event Emitters inside of a router outlet?

A

<router-outlet> does not offer a means to bind data to loaded components or emit events from them to parents.
</router-outlet>

40
Q

What is Async pipe?

A