The directive that's used to manipulate the structure of the DOM by adding/removing elements is prefixed with ________.

  • *ngFor
  • *ngIf
  • *ngSwitch
  • *ngStyle
The directive used to manipulate the DOM structure by adding or removing elements conditionally is prefixed with *ngIf in Angular. It allows you to control whether an element is rendered based on a given condition. The other options, like *ngFor, *ngSwitch, and *ngStyle, are used for different purposes in Angular and do not add or remove elements from the DOM.

What would you use to capture and act upon route parameters passed in a URL in Angular?

  • ActivatedRouteSnapshot and RouteParams
  • Router and ActivatedRoute
  • ActivatedRoute and Router
  • RouteData and RouteSnapshot
To capture and act upon route parameters in Angular, you would use ActivatedRouteSnapshot and RouteParams. These are part of the Angular Router and provide access to the parameters passed in the URL, allowing you to utilize them in your components. The other options may be components of the Angular Router, but they are not the primary tools for capturing and acting upon route parameters.

What is the primary difference between Observables and Promises?

  • Observables are only used for HTTP requests, while Promises are for other asynchronous tasks
  • Observables can handle multiple values over time, while Promises handle a single value
  • Promises are asynchronous, while Observables are synchronous
  • Promises are part of JavaScript, while Observables are part of Angular
The primary difference is that Observables can handle multiple values over time, while Promises handle a single value. Observables are often used for handling streams of data, such as events, real-time updates, or user input. Promises are better suited for handling a single asynchronous operation.

What should you do to ensure that an HTTP request is unsubscribed automatically when a component is destroyed?

  • Automatically unsubscribed by default
  • Manually unsubscribe in the ngOnDestroy lifecycle hook
  • Use the async pipe
  • Use the takeUntil() operator with a subject
To ensure that an HTTP request is unsubscribed automatically when a component is destroyed, you should use the 'takeUntil()' operator with a subject. This pattern helps prevent memory leaks by unsubscribing from observable streams when the component is no longer in use.

Which testing framework is primarily used alongside Angular for unit testing?

  • Jasmine
  • Jest
  • Mocha
  • Protractor
Jasmine is the most commonly used testing framework for unit testing in Angular applications. It provides a rich set of features for writing and running tests, including matchers for assertions and spies for tracking function calls.

The philosophy of Akita is more imperative, while NgRx is more ________.

  • Declarative
  • Procedural
  • Reactive
  • Synchronous
The philosophy of Akita is more imperative, while NgRx is more reactive. In Akita, state management is simplified and focuses on declarative approaches, making it more reactive to changes in state.

Your application's main dashboard has multiple child components displaying real-time data. To optimize performance, which strategy would you employ to ensure only relevant components are re-rendered upon data changes?

  • Memoization
  • Pure Components
  • Dynamic Imports
  • Lazy Loading
In this scenario, to ensure only relevant components are re-rendered upon data changes, you should use Pure Components. Pure Components are optimized to re-render only when their input properties change, and they don't have side effects. Memoization (Option 1) can be used for caching expensive calculations but doesn't handle re-rendering. Dynamic Imports (Option 3) and Lazy Loading (Option 4) are related to code splitting and module loading, not component rendering optimization.

Which command allows you to add a new capability, like Angular Material, to your Angular application using Angular CLI?

  • ng new
  • ng add
  • ng generate
  • ng install
To add a new capability or library to your Angular application, such as Angular Material, you can use the "ng add" command. This command not only installs the library but also performs any necessary configuration, making it a convenient way to enhance your project.

The ______ guard is used to decide if the current route can be deactivated.

  • CanActivate
  • CanActivateChild
  • CanDeactivate
  • CanLoad
In Angular, the CanDeactivate guard is used to decide if the current route can be deactivated. It's often used to prompt users for confirmation before leaving a page with unsaved changes.

When building your Angular application for production, which command ensures that Angular's AOT (Ahead of Time) compiler is used?

  • ng build --ahead-of-time
  • ng build --aot
  • ng build --optimize
  • ng build --prod
To ensure that Angular's AOT compiler is used when building your application for production, you should use the ng build --aot command. AOT compilation improves runtime performance and reduces bundle size by pre-compiling Angular templates.