Which lifecycle hook is best suited to react to changes in a component's input properties?
- ngAfterViewInit
- ngDoCheck
- ngOnChanges
- ngOnInit
The ngOnChanges lifecycle hook is best suited to react to changes in a component's input properties. It provides information about the changes to input properties.
When using Jasmine and Karma for testing, how can you ensure that a specific test or suite of tests is executed while others are ignored?
- Apply a custom test filter
- Enable verbose logging
- Set a test timeout
- Use the "xit" or "fdescribe" keywords
In Jasmine and Karma testing, you can ensure that a specific test or suite of tests is executed while others are ignored by using the "xit" (exclude it) or "fdescribe" (focus describe) keywords.
The _____ method in a Route Guard is used to check whether a user can navigate to a specific route.
- canActivate
- canDeactivate
- canNavigateTo
- checkRouteAccess
The canActivate method in a Route Guard is used to check whether a user can navigate to a specific route by returning true or false based on certain conditions.
What is the primary purpose of Dependency Injection (DI) in Angular?
- Define component behavior
- Enable two-way data binding
- Handle HTTP requests
- Manage external dependencies
The primary purpose of Dependency Injection (DI) in Angular is to manage external dependencies by providing them to a component when it's created.
What are the implications of importing a module that provides a service into multiple feature modules?
- Compilation error
- Multiple service instances
- No implications
- Shared singleton service instance
Importing a module with a service into multiple feature modules results in a shared singleton service instance, allowing data to be shared.
For more complex animation sequences, Angular animations use _______ to group multiple animation steps together.
- Animation groups
- Animation keyframes
- Animation mixins
- Animation states
In Angular animations, for more complex animation sequences, Angular uses Animation groups to group multiple animation steps together. This allows you to control and manage complex animation sequences effectively.
By using a custom _____ strategy, you can control which lazily-loaded modules should be preloaded in your Angular application.
- LazyLoading
- Loading
- ModuleLoading
- Preloading
By using a custom LazyLoading strategy, you can control which lazily-loaded modules should be preloaded in your Angular application. This optimizes the loading of modules.
The process of bundling together related capabilities into a single Angular ________ helps in organizing an application better.
- Component
- Directive
- Module
- Service
In Angular, the process of bundling related capabilities into a single Module helps in organizing an application better.
You are building a complex form that includes a dynamically generated list of items, where each item has multiple fields (e.g., name, quantity, price). How would you structure your form using Angular Reactive Forms?
- Create a FormArray to manage the list of items and use FormBuilder
- Implement a separate component for each item in the list
- Use ng-model with ng-repeat to dynamically bind form controls
- Use template-driven forms with *ngFor directive
When dealing with a dynamically generated list in Angular, you should create a FormArray to manage the list of items within a Reactive Form. This approach allows you to dynamically add and remove form controls.
In an Angular application, how would you use the async pipe to ensure that a component automatically unsubscribes from an Observable when the component is destroyed?
- Manually unsubscribe in the component
- No need to unsubscribe with async pipe
- Use *ngIf in the template
- Use a try...catch block
When using the async pipe, you don't need to manually unsubscribe; it automatically handles it. There's no need to unsubscribe when using the async pipe.