Hierarchical Dependency Injection in Angular means that if you request a service from an injector, it will retrieve it from the current injector or from any of its _____ injectors.

  • Child
  • Parent
  • Root
  • Sibling
In Angular, Hierarchical Dependency Injection means that if you request a service from an injector, it will retrieve it from the current injector or from any of its Parent injectors.

You are developing an admin panel with multiple sections (e.g., Users, Products, Orders) and want to ensure that only authenticated administrators can access these sections. How would you use Route Guards to protect these sections?

  • Apply CanLoad Route Guards to sections
  • Create a single global Route Guard for admin access
  • Implement a shared authentication service
  • Use CanActivate Route Guards for each section
To protect admin sections and ensure authentication, you should use CanActivate Route Guards for each section. These guards check if the user is authorized to access each section.

You need to build a form that fetches and populates its options (e.g., a dropdown list) from an API. Which form approach would allow you more flexibility and control over handling data asynchronously?

  • Template-driven forms
  • Reactive forms
  • Both provide the same flexibility
  • None of the above
To handle data asynchronously and fetch options from an API, Reactive forms would be the better choice as they offer more flexibility and control over handling asynchronous data.

You're experiencing a situation where your Angular application works as expected during development but breaks when running unit tests. What steps can you take to identify and rectify the discrepancy?

  • Analyze environment differences
  • Check for asynchronous code
  • Debug the failing unit tests
  • Increase unit test coverage
To identify and rectify the discrepancy between development and unit tests, you should analyze environment differences that might be affecting the tests.

In Angular, developers can use the _____ service to log errors to the console during debugging.

  • Console
  • Error
  • Http
  • Log
In Angular, developers can use the Error service to log errors to the console during debugging, making it easier to diagnose issues.

To asynchronously validate a form control value, you can use a _____ validator.

  • asyncValidator
  • mergeMap
  • subscribe
  • syncValidator
To asynchronously validate a form control value in Angular, you can use an asyncValidator.

When testing an Angular service, why might you use a spy?

  • To create a new instance of the service
  • To mock dependencies used by the service
  • To secretly record user interactions
  • To simulate service method calls
In Angular testing, you use a spy to mock dependencies used by the service being tested, allowing you to control and observe interactions with those dependencies.

In what scenario would you create a custom directive instead of using a component in Angular?

  • Handling user input
  • Implementing complex logic
  • Managing application state
  • Reusing UI behavior
You would create a custom directive in Angular when you want to reuse UI behavior across different parts of your application.

To continue processing in an Observable sequence after an error occurs, you can use the _____ operator to replace the error with a new source.

  • catchError
  • combineLatest
  • map
  • retry
To continue processing after an error in an Observable, you can use the catchError operator to replace the error with a new source.

When a navigation fails due to an unexpected error, Angular fires the _____ event.

  • NavigationCancel
  • NavigationEnd
  • NavigationError
  • NavigationStart
When a navigation fails due to an unexpected error, Angular fires the NavigationError event. This event is triggered when there is an error during navigation.