In Angular, what is the primary purpose of a component's class?

  • Define component behavior
  • Define routing
  • Handle user input
  • Store metadata
The primary purpose of a component's class in Angular is to define component behavior, including properties, methods, and event handlers.

You're building an e-commerce application and want to create a nested navigation structure where product categories have sub-categories. How would you design the routing for this scenario using child routes?

  • Configure named outlets for sub-categories
  • Define child routes within the parent component
  • Implement a shared module for navigation
  • Use auxiliary outlets for sub-categories
To create nested navigation with sub-categories, you should define child routes within the parent component. This allows for a hierarchical structure in your routing.

What is the purpose of a Form Group in Angular Reactive Forms?

  • Define form submission actions
  • Define form validation rules
  • Group related form controls
  • Store form control values
The purpose of a Form Group in Angular Reactive Forms is to group related form controls together. It helps manage and validate a set of related form controls.

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.

If a pipe takes multiple input values, how should it be tested to ensure all cases are covered?

  • Rely on integration tests to cover all possible input combinations
  • Skip testing for cases with complex input values
  • Use a single test case with multiple input values and expected results
  • Write separate test cases for each combination of input values
To ensure all cases are covered when testing a pipe with multiple input values, you should write separate test cases for each combination of input values.

To submit a form in Angular, you typically bind the submit event to a method in your component class using _____ .

  • formAction
  • formSubmit
  • ngSubmit
  • submitForm
To submit a form in Angular, you typically bind the submit event to a method in your component class using ngSubmit.

How can you pass data to a Route Guard in Angular?

  • Direct function argument
  • Query parameters
  • Router configuration
  • Shared service
In Angular, you can pass data to a Route Guard by using a Shared service to store and share data between components and guards.

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.