What method can be used to manually trigger change detection in Angular?

  • detectChanges()
  • runChangeDetection()
  • triggerChangeDetection()
  • performChangeDetection()
The detectChanges() method can be used to manually trigger change detection in Angular. It is a method of the ChangeDetectorRef class and is often used when you need to explicitly check for changes in a component, especially when dealing with components that use the OnPush change detection strategy. The other options (runChangeDetection(), triggerChangeDetection(), performChangeDetection()) are not standard Angular methods.

Which technique in Angular allows you to encapsulate styles and templates so that they don't affect other parts of the application?

  • Angular Modules.
  • Angular Services.
  • Angular Components.
  • Angular ViewEncapsulation.
Angular's ViewEncapsulation technique allows you to encapsulate styles and templates for a component so that they don't affect other parts of the application. It provides options like Emulated, None, and Shadow DOM, which control how styles are scoped to a component. The other options, such as Angular Modules and Components, serve different purposes in Angular and do not specifically address style and template encapsulation.

When setting up child routes, which directive is used in the parent component's template to display the views for the child routes?

To display the views for child routes in Angular, you use the directive in the parent component's template. This directive acts as a placeholder where the content of child routes will be rendered.

The process of splitting an Angular application into multiple bundles, where each bundle is loaded lazily on demand, is known as ________.

  • Ahead-of-Time Compilation
  • Code Splitting
  • Lazy Loading
  • Tree Shaking
The process of splitting an Angular application into multiple bundles, where each bundle is loaded lazily on demand as needed, is known as "Lazy Loading." This technique helps improve application performance by loading only the necessary code chunks when navigating to different parts of the application.

Akita promotes the idea of separating UI state from ________ state.

  • Entity
  • Feature
  • Local
  • Shared
Akita encourages the separation of UI state from Entity state. Entity state typically represents data structures and business logic, while UI state deals with presentation-specific concerns. Separating them helps in better code organization and maintainability.

How do you set default values for controls in a reactive form?

  • Default values cannot be set in reactive forms.
  • Use the default property of the FormControl.
  • Use the setValue method of the FormControl.
  • Use the value property of the FormControl.
In reactive forms, you set default values for controls by using the value property of the FormControl object. This property allows you to specify the initial value of the control. You can also use the setValue method to set the value programmatically after the control has been created. The default property is not used for setting default values in reactive forms.

What is the purpose of an HttpInterceptor in Angular?

  • Intercept and modify HTTP requests and responses
  • Manage application state
  • Render UI components
  • Validate form input
An HttpInterceptor in Angular is used to intercept and modify HTTP requests and responses before they are sent to or received from the server. This allows you to add headers, handle errors, perform logging, or make any necessary changes to the request or response pipeline globally across your application. It is a powerful tool for managing HTTP-related behaviors in a centralized manner.

In a real-time chat application, you need to ensure that even if messages are sent rapidly, only the latest message is processed and displayed. Which RxJS strategy would be most appropriate?

  • concatMap
  • debounceTime
  • exhaustMap
  • switchMap
To ensure that only the latest message is processed and displayed in a real-time chat application, you should use the exhaustMap strategy in RxJS. It ensures that only the events from the latest inner observable are propagated.

How can you redirect a user to another route within a CanActivate guard if they are not authorized?

  • Using the CanActivate.redirect method
  • Using the Route.navigate method
  • Using the Router.navigate method
  • Using the Router.redirect method
In a CanActivate guard, you can redirect a user to another route by using the Router.navigate method. This allows you to navigate the user to a different route if they are not authorized to access the current route.

When using content projection with , the projected content's change detection is the responsibility of the ________ component.

  • Angular
  • Child
  • Host
  • Parent
When using content projection with , the projected content's change detection is the responsibility of the Parent component. This means that any changes or events in the projected content will trigger change detection in the parent component that hosts the projected content. This is important for ensuring that updates in the projected content are reflected in the parent component.