Angular Flashcards
What is Single Page Web Application?
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
What are the basic building blocks of Angular Framework?
Angular Components . These are organized into NgModules.
What is NgModule in Angular?
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 do components work in angular ?
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.
What are decorators in Angular ?
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)
Why Organizing the code into distinct functional modules is necessary?
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.
Can Modules be loaded asynchronously?
Modules can be loaded eagerly when the application starts or lazy loaded asynchronously by the router.
What is a Feature Module?
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.
What is the declarations array in NgModule used for?
The declarations array is available for you to add declarables, which are components, directives, and pipes that belong exclusively to this particular module.
What is a Javascript module?
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.
What is root module?
An application always has at least a root module (App Module)that enables bootstrapping and typically has many more feature modules.
What are declarations in NgModule?
declarations: The components, directives, and pipes that belong to the NgModule. A new application project’s root NgModule has only one component, called AppComponent.
What are imports in NgModule?
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.
What are providers in NgModule?
providers: Providers of services that components in other NgModules can use. There are no providers in a newly generated root NgModule.
What is bootstrap in NgModule?
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.
What are directives in Angular?
Structural , Attribute and Components
Can we create Custom Structural and Custom Attribute directives ?
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
What is BrowserModule in Angular?
Should be imported to run your application in a browser.
What is CommonModule in Angular?
Should be used if ‘ngIf’ , ‘ngFor’ are used
What is FormsModule in Angular ?
To build template driven forms (includes NgModel).
What is ReactiveFormsModule in Angular
To build reactive forms.
What is RouterModule in Angular?
To use RouterLink, .forRoot(), and .forChild().
What is HttpClientModule in Angular?
To communicate with a server using the HTTP protocol.
Will Express accept CORS -cross origin requests (Request from other domain) ?
No , By default express doesn’t allow CORS. By using middleware CORS it is possible .