In Angular, the replaceUrl property of the _____ object can be used to navigate while replacing the current URL in the browser's history.

  • ActivatedRouteSnapshot
  • NavigationExtras
  • Router
  • RouterStateSnapshot
In Angular, the replaceUrl property of the RouterStateSnapshot object can be used to navigate while replacing the current URL in the browser's history. It allows for URL manipulation.

When testing a directive that modifies the DOM, what should you consider to ensure that the tests are not flaky?

  • Avoid testing such directives as they are inherently flaky
  • Check for DOM changes in a loop until they are detected consistently
  • Use a stubbed version of the directive to isolate DOM changes
  • Use asynchronous timers to delay test execution until the DOM changes
To prevent flaky tests when testing a directive that modifies the DOM, use a stubbed version of the directive to isolate DOM changes and ensure reliable testing.

What does the async pipe do in an Angular template?

  • Handles routing
  • Renders HTML
  • Subscribes to an Observable
  • Transforms data
The async pipe in an Angular template subscribes to an Observable and automatically updates the view with the most recent data emitted by the Observable. It simplifies working with asynchronous data in templates.

Which lifecycle hook is best suited to react to changes in a component's input properties?

  • ngAfterViewInit
  • ngDoCheck
  • ngOnChanges
  • ngOnInit
The ngOnChanges lifecycle hook is best suited to react to changes in a component's input properties. It provides information about the changes to input properties.

When using Jasmine and Karma for testing, how can you ensure that a specific test or suite of tests is executed while others are ignored?

  • Apply a custom test filter
  • Enable verbose logging
  • Set a test timeout
  • Use the "xit" or "fdescribe" keywords
In Jasmine and Karma testing, you can ensure that a specific test or suite of tests is executed while others are ignored by using the "xit" (exclude it) or "fdescribe" (focus describe) keywords.

For more complex animation sequences, Angular animations use _______ to group multiple animation steps together.

  • Animation groups
  • Animation keyframes
  • Animation mixins
  • Animation states
In Angular animations, for more complex animation sequences, Angular uses Animation groups to group multiple animation steps together. This allows you to control and manage complex animation sequences effectively.

By using a custom _____ strategy, you can control which lazily-loaded modules should be preloaded in your Angular application.

  • LazyLoading
  • Loading
  • ModuleLoading
  • Preloading
By using a custom LazyLoading strategy, you can control which lazily-loaded modules should be preloaded in your Angular application. This optimizes the loading of modules.

The process of bundling together related capabilities into a single Angular ________ helps in organizing an application better.

  • Component
  • Directive
  • Module
  • Service
In Angular, the process of bundling related capabilities into a single Module helps in organizing an application better.

You are building a complex form that includes a dynamically generated list of items, where each item has multiple fields (e.g., name, quantity, price). How would you structure your form using Angular Reactive Forms?

  • Create a FormArray to manage the list of items and use FormBuilder
  • Implement a separate component for each item in the list
  • Use ng-model with ng-repeat to dynamically bind form controls
  • Use template-driven forms with *ngFor directive
When dealing with a dynamically generated list in Angular, you should create a FormArray to manage the list of items within a Reactive Form. This approach allows you to dynamically add and remove form controls.

In an Angular application, how would you use the async pipe to ensure that a component automatically unsubscribes from an Observable when the component is destroyed?

  • Manually unsubscribe in the component
  • No need to unsubscribe with async pipe
  • Use *ngIf in the template
  • Use a try...catch block
When using the async pipe, you don't need to manually unsubscribe; it automatically handles it. There's no need to unsubscribe when using the async pipe.