When a service is provided at the root level, it is available throughout the entire _____.

  • application
  • application module
  • component
  • module
When a service is provided at the root level, it is available throughout the entire application.

You are building an admin panel where certain routes should only be activated if the user has the required permissions. How can you utilize Route Resolvers to ensure that the data indicating permission is fetched before navigation?

  • Implement an Angular Service to fetch data
  • Include a custom Angular directive
  • Use a Route Resolver
  • Utilize Route Guards
To ensure that data indicating permissions is fetched before navigation, you can utilize a Route Resolver. The resolver can fetch the required data and halt route activation until the data is available and evaluated for permissions.

In Angular, a service is typically injected into a component's constructor through the component's _____.

  • constructor
  • ngInject
  • ngOnChanges
  • ngOnInit
In Angular, a service is typically injected into a component's constructor through the component's constructor.

In NgRx, the _____ is responsible for changing the state based on the action received.

  • Dispatcher
  • Effect
  • Reducer
  • Selector
In NgRx, the Reducer is responsible for changing the state based on the action received. A reducer defines how the state should change.

How can you preload some, but not all, of the lazily-loaded modules in an Angular application?

  • It's not possible
  • Setting the 'preload' property
  • Using canActivateChild guard
  • Using the preloadStrategy
You can preload some, but not all, of the lazily-loaded modules in Angular by specifying the preloadStrategy in the route configuration.

When using NgRx, how can you prevent unnecessary re-rendering of components when the state changes?

  • Use ChangeDetectionStrategy.OnPush
  • Use ChangeDetectorRef.markForCheck
  • Use pure pipes
  • Use the async pipe
In NgRx, you can prevent unnecessary re-rendering of components by using ChangeDetectionStrategy.OnPush to only update components when necessary.

To perform side-effect-free computations synchronously, Angular provides a testing utility known as _____.

  • HttpClientTestingModule
  • JasmineSpy
  • MockAsyncService
  • TestBed
To perform side-effect-free computations synchronously in Angular, you can use the TestBed utility for creating and configuring testing modules.

How can a parent component communicate with a child component without using @Input or @Output?

  • Use BehaviorSubject and Renderer2
  • Use Dependency Injection and ElementRef
  • Use EventEmitter and ViewChildren
  • Use ViewChild and ElementRef
A parent component can communicate with a child component without @Input or @Output by using ViewChild and ElementRef to access the child's properties and methods directly.

To create a dynamic form in Angular, developers often use the ____ class to programmatically add form controls.

  • FormArray
  • FormControl
  • FormGroup
  • NgForm
To create a dynamic form in Angular, developers often use the FormArray class to programmatically add form controls. A FormArray is used when you need to manage a list of form controls.

You are building a complex form that needs to enable or disable sections of the form based on user input. Which type of form would be more suitable to implement this, and why?

  • Both are equally suitable
  • None of the above
  • Reactive forms
  • Template-driven forms
To enable or disable sections of a form based on user input, Reactive forms would be more suitable because they provide greater programmatic control and flexibility.