In Angular, when you want to make sure that a service gets instantiated lazily, only when it is needed, you should use _____.

  • Eager instantiation
  • Lazy loading
  • On-demand service
  • Singleton
In Angular, to ensure that a service gets instantiated lazily, only when needed, you should use Lazy loading.

The _____ event is emitted when a navigation action starts.

  • NavigationCancel
  • NavigationEnd
  • NavigationError
  • NavigationStart
The blank should be filled with NavigationStart. The NavigationStart event is emitted when a navigation action starts in Angular.

The _____ Subject will emit its most recent value to all subscribers whenever they subscribe.

  • Async
  • Behavior
  • Multicast
  • Replay
The Behavior Subject will emit its most recent value to all subscribers whenever they subscribe. It stores and shares the last emitted value among subscribers.

To selectively apply styles based on component logic, you can use ngClass binding in Angular.

  • ngFor
  • ngIf
  • ngStyle
  • ngSwitch
In Angular, the ngClass binding is used to selectively apply styles based on component logic by dynamically adding or removing CSS classes.

How can you ensure that a service provides a single, shared instance across an entire Angular application?

  • Using a local provider in a component
  • Using providedIn property
  • Using the @Injectable() decorator
  • Using the @Singleton() decorator
To ensure a service provides a single, shared instance across an entire Angular application, you can use the providedIn property in the @Injectable decorator and specify a module where the service should be provided. This ensures a singleton instance.

In Angular, the _____ method is used to assert that a certain expectation is met in tests.

  • beforeEach
  • describe
  • expect
  • it
The correct term to fill in the blank is expect. In Angular testing, you use the expect method from Jasmine to assert that a specific expectation is met during tests.

How can you create a custom validator that depends on multiple form controls?

  • Combine validators in a custom validation function
  • Use a directive for form validation
  • Use a reactive approach
  • Use a template-driven approach
In Angular, you can create a custom validator that depends on multiple form controls by combining validators in a custom validation function. This allows you to implement complex validation logic that relies on the values of multiple form controls.

What is the purpose of the inject() function in Angular testing?

  • To create a new Angular component
  • To inject dependencies into a test function
  • To perform asynchronous testing with Observables
  • To retrieve HTTP responses in testing
The inject() function in Angular testing is used to inject dependencies into a test function, making it easier to access and use Angular services and components in your tests.

In a NgRx setup, the _______ function is used to create a new state object by copying the existing state and making changes to it.

  • createAction
  • createEffect
  • createReducer
  • createSelector
In a NgRx setup, the createReducer function is used to create a new state object by copying the existing state and making changes to it. This is a fundamental part of state management in NgRx.

How can you handle side effects in state management when using NgRx?

  • Use Callback functions
  • Use Observables
  • Use Promises
  • Use setTimeout
When using NgRx, you typically handle side effects by using Observables to manage asynchronous operations that interact with the state.