Which of the following is NOT a method available on ViewContainerRef?

  • clear
  • createEmbeddedView
  • detach
  • detectChanges
detectChanges is not a method available on ViewContainerRef. ViewContainerRef is primarily used for manipulating the view container's content, including creating embedded views, detaching, and clearing views. detectChanges is typically used on a ChangeDetectorRef to trigger change detection in Angular.

When the ViewEncapsulation.Emulated mode is used, Angular adds unique ________ to styles to achieve scoped styling.

  • CSS IDs
  • CSS classes
  • attribute selectors
  • pseudo-elements
When Angular uses the ViewEncapsulation mode "Emulated," it adds unique CSS classes to styles to achieve scoped styling. This means that styles defined in one component won't affect styles in other components, ensuring encapsulation and preventing unintended CSS conflicts. The unique CSS classes are generated dynamically to maintain separation between components, enhancing modularity and maintainability in Angular applications.

To intercept and modify HTTP requests globally, you would implement a class that uses the ________ interface.

  • HttpClient
  • HttpHandler
  • HttpInterceptor
  • HttpRequest
To intercept and modify HTTP requests globally in an Angular application, you would implement a class that uses the HttpInterceptor interface. This interface provides methods for intercepting both the request and the response, allowing you to add headers, modify requests, or handle errors at a global level.

In large applications, frequent change detection cycles can lead to performance issues, especially if the application does not use the ________ change detection strategy.

  • CheckOnce
  • Default
  • OnPush
  • Push
In large Angular applications, frequent change detection cycles can indeed lead to performance issues. By default, Angular uses the Default change detection strategy, which checks all components in each cycle. To address this, developers can use the ChangeDetectionStrategy.OnPush strategy, which limits change detection to components that receive input changes or manually trigger detection, significantly improving performance for large applications.

Which method of the ControlValueAccessor interface is called to write a new value from the form model into the view?

  • writeValue
  • registerOnChange
  • registerOnTouched
  • setViewValue
In the context of the ControlValueAccessor interface in Angular, the writeValue method is responsible for writing a new value from the form model into the view. This method is used to update the UI with the latest value when there are changes in the underlying data model. The other options (registerOnChange, registerOnTouched, setViewValue) have different responsibilities related to handling form control interactions but are not used for updating the view with new values.

When setting up routing in Angular, where do you usually define the paths and their associated components?

  • In a separate routing module file.
  • In the app.component.ts file.
  • In the app.module.ts file.
  • In the index.html file.
In Angular, paths and their associated components are typically defined in a separate routing module file. This separation helps organize and manage routing configurations more effectively. While it's possible to define routes in other files, the recommended and conventional approach is to use a dedicated routing module.

Which attribute can be added to a form control to make it required?

  • [ngRequired]
  • [required]
  • [validate]
  • [isRequired]
In template-driven forms, the [required] attribute can be added to a form control to make it required. When this attribute is present on an input element, the user must fill in the control before submitting the form. It's a simple way to implement basic form validation for mandatory fields. The other options are not standard attributes for making form controls required in Angular template-driven forms.

In the context of NgRx, when an action is dispatched, it is processed by a ________ to produce a new state.

  • Effect
  • Middleware
  • Reducer
  • Selector
In the context of NgRx, when an action is dispatched, it is processed by a "Reducer" to produce a new state. Reducers are pure functions that specify how the state should change based on the action type and payload.

What's the purpose of the FormBuilder service in Angular's reactive forms?

  • It's used for styling forms with CSS.
  • It's used to create form controls manually.
  • It's used to handle HTTP requests in forms.
  • It's used to simplify the creation of form controls.
The FormBuilder service in Angular's reactive forms is used to simplify the creation of form controls and form groups. It provides a more concise and readable way to define form structures compared to manually creating controls. While Angular also uses HTTP for handling HTTP requests in forms, this is not the primary purpose of FormBuilder. It's primarily focused on form control management.

Which Angular CLI command is used to generate a new service?

  • ng create service
  • ng generate service
  • ng make service
  • ng new service
To generate a new service in an Angular application, you should use the ng generate service command. This command creates the service file, sets up the necessary imports, and registers the service with the Angular dependency injection system.