To selectively apply styles based on component logic, you can use ngClass binding in Angular.

  • ngFor
  • ngIf
  • ngStyle
  • ngSwitch
In Angular, the ngClass binding is used to selectively apply styles based on component logic by dynamically adding or removing CSS classes.

What is the purpose of the inject() function in Angular testing?

  • To create a new Angular component
  • To inject dependencies into a test function
  • To perform asynchronous testing with Observables
  • To retrieve HTTP responses in testing
The inject() function in Angular testing is used to inject dependencies into a test function, making it easier to access and use Angular services and components in your tests.

In a NgRx setup, the _______ function is used to create a new state object by copying the existing state and making changes to it.

  • createAction
  • createEffect
  • createReducer
  • createSelector
In a NgRx setup, the createReducer function is used to create a new state object by copying the existing state and making changes to it. This is a fundamental part of state management in NgRx.

How can you handle side effects in state management when using NgRx?

  • Use Callback functions
  • Use Observables
  • Use Promises
  • Use setTimeout
When using NgRx, you typically handle side effects by using Observables to manage asynchronous operations that interact with the state.

In Angular, how can you optimize form submission to prevent multiple submissions of the same data?

  • Disable the submit button after the first click
  • Implement server-side deduplication
  • Use a unique key for each form submission
  • Use debouncing techniques
In Angular, you can optimize form submission to prevent multiple submissions by disabling the submit button after the first click.

You have a suite of E2E tests written using Protractor, and a particular test is flaky, occasionally failing without any code changes. What approach can you take to identify and resolve the issue?

  • Debug the test
  • Disable the test
  • Rerun the test multiple times
  • Rewrite the entire suite of tests
When encountering flaky tests in Protractor, the best approach is to debug the test to identify the root cause of the flakiness and make necessary adjustments. Rerunning the test multiple times or disabling it may not address the underlying problem. Rewriting the entire test suite is typically an overkill solution.

How can you nest one component inside another in Angular?

  • Using an ng-container
  • Using ng-template
  • Using structural directives
  • Using the @ViewChild decorator
You can nest one component inside another in Angular by using the @ViewChild decorator to reference the child component within the parent.

In an e-commerce application, you need to create a checkout form that dynamically adds input fields based on the items in the user's cart. Which Angular concept can help you achieve this?

  • Dynamic Component Creation
  • One-way Data Binding with [ngModel]
  • Router Guards for Dynamic Routing
  • Service Injection
To dynamically add input fields based on cart items, you can use Dynamic Component Creation in Angular. This allows you to generate components on the fly based on user interactions.

The _____ operator is used to catch and handle errors within an Observable sequence.

  • catchError
  • filter
  • map
  • retry
The catchError operator is used to catch and handle errors within an Observable sequence. It allows you to gracefully handle errors in your observable stream.

To add a third-party library to an Angular project, you can use the _____ command of Angular CLI.

  • ng add
  • ng compile
  • ng generate
  • ng serve
To add a third-party library to an Angular project, you can use the ng add command of Angular CLI.