To continue processing in an Observable sequence after an error occurs, you can use the _____ operator to replace the error with a new source.

  • catchError
  • combineLatest
  • map
  • retry
To continue processing after an error in an Observable, you can use the catchError operator to replace the error with a new source.

In what scenario would you create a custom directive instead of using a component in Angular?

  • Handling user input
  • Implementing complex logic
  • Managing application state
  • Reusing UI behavior
You would create a custom directive in Angular when you want to reuse UI behavior across different parts of your application.

When testing an Angular service, why might you use a spy?

  • To create a new instance of the service
  • To mock dependencies used by the service
  • To secretly record user interactions
  • To simulate service method calls
In Angular testing, you use a spy to mock dependencies used by the service being tested, allowing you to control and observe interactions with those dependencies.

What is the main difference between the combineLatest and withLatestFrom operators in RxJS?

  • combineLatest emits only when all sources emit sequentially
  • combineLatest emits only when all sources emit simultaneously
  • withLatestFrom emits only when all sources emit simultaneously
  • withLatestFrom emits when the source emits and the other observable emits, but not necessarily simultaneously
The main difference between combineLatest and withLatestFrom is that combineLatest emits when all sources emit simultaneously, while withLatestFrom emits when the source emits and the other observable emits, but not necessarily simultaneously.

Imagine you're building an Angular application that involves creating a directive to apply dynamic styling to elements. How can you pass values to your custom directive to make it reusable across different elements?

  • Pass values through the DOM using attributes
  • Use a service to share data between elements
  • Use global variables to store values
  • Use the @Input decorator to pass values as input properties
To make a directive reusable across different elements, you should use the @Input decorator to pass values as input properties.

Your Angular application includes a form that users utilize to submit sensitive data. How can you ensure that the form data is only submitted once, even if the user accidentally clicks the submit button multiple times?

  • Implement a server-side mechanism that tracks and validates submitted data
  • Use a client-side timer to disable the submit button for a fixed duration
  • Use client-side JavaScript to check for duplicate submissions
  • Utilize Angular guards to prevent multiple form submissions
To ensure that sensitive form data is submitted only once, you should utilize Angular guards to prevent multiple submissions. Angular guards allow you to control navigation and actions within your application.

How can you apply a custom validator to a form control in Angular?

  • Applying ngFor directive
  • By extending the FormControl class
  • Using the async pipe
  • Using the ngIf directive
You can apply a custom validator to a form control in Angular by extending the FormControl class and implementing your validation logic within it.

When using Angular Elements, what considerations must be taken into account for handling data and events in the custom element?

  • Avoiding data sharing between components
  • Direct DOM manipulation
  • Ensuring data encapsulation and event emitters
  • Use Angular services for data communication
When working with Angular Elements, it's important to use Angular services for data communication to ensure proper encapsulation and handling of data and events.

How can you display validation error messages for a custom validator in Angular?

  • Use Reactive Forms
  • Use a FormBuilder
  • Use a FormGroup
  • Use a Validation Message
To display validation error messages for a custom validator in Angular, you can use a Validation Message. This involves creating custom error messages and binding them to the form control to inform users of validation issues.

To validate that at least one control within a Form Array has a specific value, you would use a _______ validator.

  • Array
  • Custom
  • MinLength
  • Required
To validate that at least one control within a Form Array has a specific value, you would use a Custom validator. A custom validator allows you to define your own validation logic.

Which RxJS operator would you use to combine multiple Observables into a single Observable?

  • combineLatest()
  • concatMap()
  • reduce()
  • switchMap()
To combine multiple Observables into a single Observable, you can use the combineLatest() operator, which emits a new value when any of the source Observables emits a new value.

What does the routerLink directive do in Angular?

  • It creates a new Angular project
  • It defines a component's class
  • It defines a route in the application
  • It displays a component in the template
The routerLink directive in Angular is used to define a route in the application. It specifies the route to navigate to when a user interacts with the element containing this directive.