Which Angular feature allows you to load certain modules only when they are needed?

  • Dependency Injection
  • Lazy Loading
  • Observables
  • Routing
The Angular feature that allows you to load certain modules only when they are needed is Lazy Loading. Lazy loading helps optimize your application's performance by loading modules on-demand, making it a key technique for improving user experience.

For optimal performance and faster initial page loads, Angular recommends using ______ compilation.

  • Ahead-of-Time (AOT)
  • Dynamic
  • Just-in-Time (JIT)
  • On-Demand
Angular recommends using Ahead-of-Time (AOT) compilation for optimal performance. AOT compiles Angular templates at build time, resulting in smaller bundle sizes and faster initial page loads because there's no need to compile templates in the browser.

In Ngxs, the @______ decorator is used to define state.

  • Action
  • Selector
  • State
  • Store
In Ngxs, the @State decorator is used to define state. It's used to decorate a class that represents a piece of state in the application. This decorator provides metadata about the state class, allowing Ngxs to manage and use this state within the application.

What is the significance of the RouterLinkActive directive?

  • It provides a way to check if a route is currently active, allowing for dynamic styling of navigation links.
  • It controls the navigation flow between different routes in an Angular application.
  • It determines the order in which route guards are executed.
  • It automatically adds query parameters to route links.
The RouterLinkActive directive is significant in Angular as it allows you to check if a route is currently active, enabling dynamic styling of navigation links. This is particularly useful for highlighting the active link in navigation menus. The other options do not accurately describe the purpose or significance of the RouterLinkActive directive.

Where in an Angular application would you typically define child routes?

  • In a separate routing module
  • In the app.component.ts file
  • In the app.module.ts file
  • In the parent component's template
Child routes in an Angular application are typically defined in a separate routing module dedicated to the feature module or component that contains those child routes. This helps organize the routing configuration and keep it modular.

After applying AOT compilation, a developer notices that certain dynamic components no longer render correctly. What could be a potential reason for this?

  • AOT compilation doesn't affect dynamic components
  • Dynamic components rely on JIT compilation
  • Incorrect use of NgModule declarations
  • Incorrect use of lazy loading
After AOT compilation, it's essential to ensure that all components, including dynamic ones, are properly declared in Angular's NgModule metadata. If a dynamic component is not declared correctly, it may not render as expected.

Which RxJS operator is best suited for handling side effects?

  • filter
  • map
  • reduce
  • tap
The tap operator is specifically designed for handling side effects in RxJS. It allows you to perform actions or computations without affecting the original data stream. Common side effects include logging, making HTTP requests, or modifying external state.

How can you serve your Angular application locally using Angular CLI?

  • ng build
  • ng run
  • ng serve
  • ng start
To serve your Angular application locally during development, you should use the ng serve command. This command compiles your application, starts a development server, and opens it in a web browser. It also provides features like automatic reloading when you make code changes.

What is the primary purpose of services in Angular?

  • Defining component templates.
  • Handling HTTP requests and sharing data.
  • Managing the application's routing.
  • Storing configuration settings.
The primary purpose of services in Angular is to handle HTTP requests and share data between different components. Services act as a central place to manage data and provide methods for components to interact with that data. While services can be used for other purposes like routing or storing configuration, their primary role is data management and communication between parts of an Angular application.

To dynamically load and view a component without adding it to a module's entry components, you would utilize ______.

  • ComponentFactoryResolver
  • DynamicComponentLoader
  • ComponentFactory
  • ComponentLoader
In Angular, to dynamically load and view a component without adding it to a module's entry components, you would utilize the ComponentFactoryResolver. This service provides a way to create component factories dynamically, which can then be used to create instances of components at runtime. The other options are not commonly used for this purpose.