The ______ guard is used to decide if the current route can be deactivated.
- CanActivate
- CanActivateChild
- CanDeactivate
- CanLoad
In Angular, the CanDeactivate guard is used to decide if the current route can be deactivated. It's often used to prompt users for confirmation before leaving a page with unsaved changes.
The ________ guard is used in Angular to decide if a route can be activated.
- Auth
- CanActivate
- Permission
- RouteActivation
The blank should be filled with "CanActivate." In Angular, the CanActivate guard is used to determine if a route can be activated based on certain conditions or permissions. It plays a crucial role in controlling access to routes and ensuring security in Angular applications.
Which lifecycle hook is called once when the component is initialized?
- ngAfterViewInit
- ngOnChanges
- ngOnDestroy
- ngOnInit
The ngOnInit lifecycle hook is called once when the component is initialized. It's a common place to put initialization logic for a component. ngOnChanges is called when input properties change, ngOnDestroy is called when the component is about to be destroyed, and ngAfterViewInit is called after the view has been initialized.
In RxJS, which operator is commonly used to handle side effects?
- filter
- map
- mergeMap
- tap
In RxJS, the tap operator is commonly used to handle side effects. It allows you to perform actions or execute code for each emitted item without modifying the item itself, making it suitable for logging, debugging, or triggering side effects.
The method ______ is called just before Angular destroys the component.
- ngAfterViewInit
- ngOnChanges
- ngOnDestroy
- ngOnInit
The method ngOnDestroy is called just before Angular destroys a component. Developers can use this method to perform cleanup tasks, such as unsubscribing from observables, releasing resources, or canceling ongoing operations, before the component is removed from the DOM. It's a crucial part of component lifecycle management in Angular.
What is the primary use of ComponentFactoryResolver in Angular?
- To create instances of Angular components dynamically.
- To handle HTTP requests.
- To manage routing in Angular applications.
- To style Angular components.
The primary use of ComponentFactoryResolver in Angular is to create instances of Angular components dynamically at runtime. This allows you to dynamically load and render components based on user interactions or other conditions, which is a common requirement in many Angular applications. The other options are not the primary purpose of ComponentFactoryResolver.