To enable lazy loading in Angular, you need to use the _____ property in your routing configuration.
- enableLazyLoad
- lazyLoad
- loadChildren
- routeLazy
To enable lazy loading in Angular, you need to use the loadChildren property in your routing configuration to specify the module to load lazily.
What technique can be used to ensure that an observable is automatically unsubscribed from, even if it was not manually unsubscribed?
- Angular automatically unsubscribes all observables by default.
- Employing the finalize operator to ensure automatic unsubscription.
- Implementing a custom unsubscription handler function.
- Using the unsubscribe method in a subscription.
To ensure that an observable is automatically unsubscribed, you can use the finalize operator, which allows for automatic cleanup when the observable completes, errors, or is unsubscribed. It is a good practice to prevent memory leaks.
The _____ decorator is used to mark a class as available to be provided and injected as a dependency.
- @Component
- @Dependency
- @Injectable
- @Service
The @Injectable decorator is used to mark a class as available to be provided and injected as a dependency in Angular.
You have an Angular form where users can input an email address. You want to check in real-time whether the email address is already registered in your system. Which type of validation would be suitable for this?
- Async Validators that perform server-side checks.
- Built-in Validators like required and email.
- Custom Synchronous Validators with JavaScript functions.
- Pattern Validators with regular expressions.
To check in real-time whether an email address is already registered, you should use Async Validators that perform server-side checks, allowing you to query the server for existing email addresses.
What is the primary purpose of two-way data binding in Angular?
- Handle user input
- Send data from template to class
- Synchronize data between class & template
- Trigger events automatically
The primary purpose of two-way data binding in Angular is to synchronize data between the component's class and its template, allowing changes in one to reflect in the other, making it useful for forms and interactive UI elements.
To ensure proper cleanup and prevent memory leaks, it's important to unsubscribe from observables when they are no longer needed.
- close
- complete
- disconnect
- unsubscribe
To ensure proper cleanup and prevent memory leaks, it's important to unsubscribe from observables when they are no longer needed.
What is the purpose of the RouterModule in Angular?
- Creating components
- Handling HTTP requests
- Managing forms
- Managing navigation
The purpose of the RouterModule in Angular is to manage navigation within an Angular application. It allows you to configure routes and define which component should be displayed for a given route.
How can you dynamically add form controls in reactive forms?
- Editing the template
- Using Two-way data binding
- Using ngModel
- Using the FormBuilder service
You can dynamically add form controls in reactive forms by using the FormBuilder service provided by Angular. This service allows you to create and manage form controls dynamically.
In Angular, to manually control the emission of values in an Observable, you can use a _____.
- BehaviorSubject
- Pipe
- Subject
- combineLatest
In Angular, to manually control the emission of values in an Observable, you can use a Subject.
To test a component as a whole, including its interaction with child components, you should use _____ testing.
- e2e
- integration
- mock
- unit
To test a component as a whole, including its interaction with child components, you should use integration testing. This allows testing the component's behavior in a broader context.