How can you handle errors in an Observable stream using RxJS operators?

  • catchError()
  • filter()
  • map()
  • mergeMap()
You can handle errors in an Observable stream using the catchError() operator, which allows you to catch and handle errors in the stream.

Which testing framework is commonly used for writing unit tests in Angular applications?

  • Jasmine
  • Jest
  • Mocha
  • Protractor
Jasmine is a commonly used testing framework for writing unit tests in Angular applications. It provides a suite of functions to create and run tests.

In RxJS, to ensure that resources like subscriptions are released when an Observable completes or errors out, you can use the _____ operator.

  • distinctUntilChanged
  • filter
  • finalize
  • takeUntil
To ensure resource cleanup when an Observable completes or errors out, you can use the finalize operator in RxJS.

How do you inject a service into an Angular component?

  • In the component's constructor
  • Using HTML attributes
  • Via @NgModule metadata
  • With an external JavaScript file
You inject a service into an Angular component by including it as a parameter in the component's constructor. This allows the component to use the service's methods and properties.

To apply a function to each item emitted by an Observable, you use the _____ operator in RxJS.

  • combineLatest
  • pluck
  • take
  • tap
To apply a function to each item emitted by an Observable, you use the tap operator in RxJS. The tap operator is typically used for side effects without modifying the values emitted.

To create a form control that can hold an array of values, Angular provides the _______ class.

  • ArrayControl
  • FormArray
  • FormControlArray
  • FormGroupArray
To create a form control that can hold an array of values, Angular provides the FormArray class. A FormArray is a part of Angular's reactive forms, and it can hold an array of FormControls or other FormArrays.

What is the primary difference between template-driven forms and reactive forms in Angular?

  • Reactive forms are easier to work with for simple forms.
  • Reactive forms are less flexible than template-driven forms.
  • Template-driven forms rely on two-way data binding.
  • Template-driven forms use a reactive approach.
The primary difference between template-driven forms and reactive forms is that template-driven forms rely on two-way data binding, while reactive forms are based on a more reactive and declarative approach using FormControl objects.

You have a logging service that logs errors to the console in the development environment and sends them to the server in the production environment. How can you switch between different implementations of the logging service depending on the environment?

  • Using 'app.module.ts' file
  • Using 'config.json' file
  • Using 'environment.ts' configuration
  • Using a separate service for each environment
To switch between different implementations of the logging service based on the environment, you can use the 'environment.ts' configuration, which allows you to specify different configurations for each environment.

What is the purpose of using AbstractControl in reactive forms?

  • Handle HTTP requests
  • Handle routing in Angular
  • Manage form validation and user input state
  • Render component views
AbstractControl is used to manage form validation and user input state in reactive forms. It represents a form control, such as an input field, and provides validation and interaction capabilities.

The _____ function is used to compose multiple validators into a single function that combines their effects.

  • asyncValidator
  • combineLatest
  • composeValidators
  • validateControl
In Angular, the composeValidators function is used to compose multiple validators into a single function that combines their effects.