The HostListener decorator in custom directives listens to ________ events.

  • Custom
  • DOM
  • Input
  • Mouse
The HostListener decorator in custom directives listens to DOM events. It is used to subscribe to DOM events and perform custom actions when those events occur. The decorator takes the event name as an argument, allowing you to specify which DOM event the directive should listen for and respond to. This is a fundamental concept when working with Angular custom directives.

When using the Angular CLI, which option ensures the application is built for production?

  • ng serve
  • ng build
  • ng test
  • ng lint
When building an Angular application for production, you should use the "ng build" command with the "--prod" flag. This flag enables optimizations like Ahead-of-Time (AOT) compilation, minification, and tree shaking to create a smaller and more efficient production bundle.

Which Angular decorator is used to define a component's metadata?

  • @Component
  • @Directive
  • @Injectable
  • @NgModule
In Angular, the @Component decorator is used to define a component's metadata, including its selector, template, and other properties. This decorator is crucial for marking a TypeScript class as an Angular component. The other decorators mentioned are used for different purposes, such as defining modules, services, or custom directives.

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.

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.

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.

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.

Your application's components have styles that are unexpectedly affecting other unrelated components. How would you ensure that component styles are isolated and don't interfere with other parts of the application?

  • Use ViewEncapsulation.Emulated in component metadata
  • Use global stylesheets for component-specific styles
  • Apply unique CSS classes to each component and prefix all CSS selectors with these classes
  • Set the CSS 'all' property to 'initial' for the component's root element
To ensure that component styles are isolated and don't interfere with other parts of the application, you would use ViewEncapsulation.Emulated in the component's metadata. This encapsulation mode creates unique CSS selectors for each component, preventing unintended style inheritance. The other options may not provide the same level of style isolation and control.

In a Route Guard, to navigate to a different route due to an authorization failure, you would typically use the router.______ method.

  • forwardTo
  • handleError
  • navigate
  • redirectTo
In a Route Guard, to navigate to a different route due to an authorization failure, you would typically use the router.navigate method. This allows you to redirect the user to a different route when authorization fails or when specific conditions are not met.

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.

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.

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.