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.
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.
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.
You are building an e-commerce application and want to ensure that product details are fully loaded before navigating to the product detail page. Which feature of Angular's router would you use to achieve this?
- Angular Lifecycle Hooks
- Route Guards
- Router Interceptors
- Router Resolvers
To ensure that product details are fully loaded before navigating, you can utilize Router Resolvers. A resolver can fetch data asynchronously before activating a route, ensuring that the data is available when the route is displayed.
In Angular, the _____ class is used to create form controls in reactive forms.
- FormBuilder
- FormControl
- FormGroup
- ReactiveFormsModule
In Angular, the FormControl class is used to create form controls in reactive forms.
In template-driven forms, form controls are automatically created by Angular using the _____.
- FormControlDirective
- FormsModule
- NgModel
- TemplateDirective
In template-driven forms, form controls are automatically created using the NgModel directive.
In NgRx, the _____ property of an action usually contains additional information or context.
- Action
- Meta
- Payload
- Type
In NgRx, the Meta property of an action usually contains additional information or context that can be helpful when processing the action.
To test directives with dependencies, Angular provides the _______ class which allows you to inject dependencies and spy on their usage.
- ComponentFixture
- TestBed
- TestBedDependency
- TestBedStub
To test directives with dependencies, Angular provides the TestBed class, which allows you to configure testing modules and inject dependencies.
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.
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.
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.
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.