What does a service in Angular typically consist of?

  • Component behavior
  • Dependency Injection
  • HTML and CSS
  • Reusable application logic
In Angular, a service typically consists of reusable application logic, such as data manipulation, communication with servers, or shared functionality.

To execute the Observable and start emitting values, you need to call the _____ method.

  • emit()
  • execute()
  • start()
  • subscribe()
To execute the Observable and start emitting values, you need to call the subscribe() method. This method subscribes to the Observable and listens for emitted values.

Which RxJS operator is commonly used to filter items emitted by an Observable based on a condition?

  • catchError
  • filter
  • switchMap
  • takeUntil
The RxJS operator commonly used to filter items emitted by an Observable based on a condition is filter. It allows you to specify a predicate function to determine which items should be included in the output.

How can you access a specific form control within a form group in Angular?

  • Using form.get()
  • Using formArray
  • Using formControl
  • Using formGroup.get()
You can access a specific form control within a form group in Angular by using the **formGroup.get()** method. It allows you to retrieve a form control by its name.

In a real-time data streaming application built with Angular, you want to ensure that multiple components receive the same data from an observable without creating multiple subscriptions. What kind of observable would you use?

  • AsyncSubject
  • BehaviorSubject
  • ReplaySubject
  • Subject
To ensure multiple components receive the same data from an observable without multiple subscriptions, you would use a ReplaySubject. It replays the latest emitted value to all new subscribers.

How does Angular Universal handle asynchronous operations like HTTP requests on the server side?

  • Angular Universal doesn't handle asynchronous operations
  • It blocks asynchronous operations during SSR
  • It relies on client-side code to handle HTTP requests
  • It uses server-side equivalents of Angular services
Angular Universal handles asynchronous operations like HTTP requests on the server side by using server-side equivalents of Angular services to make these requests.

In Angular testing, the ______ is used to create a controlled test environment around the directive.

  • ComponentFixture
  • HttpClientTestingModule
  • NgModule
  • TestBed
In Angular testing, the TestBed is used to create a controlled test environment around the directive, allowing you to configure and set up your tests.

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.