In what scenario would you use the fragment property of the NavigationExtras object?
- For routing configuration
- For smooth scrolling
- To handle query parameters
- To manage lazy loading
The fragment property of the NavigationExtras object is used for smooth scrolling to a specific location on a page after navigation.
How can you access the data resolved by a Route Resolver within a component?
- Using a decorator
- Using a function
- Using a service
- Using an observable
You can access data resolved by a Route Resolver within a component using an observable returned by the ActivatedRoute service.
What is the purpose of a lazy-loaded module in Angular?
- To decrease initial bundle size
- To ensure a module is always loaded
- To improve application performance
- To simplify routing configuration
The purpose of a lazy-loaded module in Angular is to decrease the initial bundle size by loading the module on-demand, typically when a user navigates to a specific route. This helps improve application performance.
You want to implement a feature that prompts the user if they try to navigate away from a form without saving changes. Which Route Guard would you use to achieve this?
- CanActivate Route Guard
- CanDeactivate Route Guard
- CanLoad Route Guard
- Resolve Route Guard
To prompt the user when navigating away from a form, you should use the CanDeactivate Route Guard. It checks if the form can be deactivated without saving changes.
In Angular, the data fetched by the Route Resolver can be accessed in the component through the route's _____ property.
- data
- params
- queryParams
- routeData
The blank should be filled with data. The data fetched by the Route Resolver can be accessed in the component through the route's data property.
What does the ChangeDetectionStrategy.OnPush strategy signify in an Angular component?
- Automatic change detection
- Manual change detection
- No change detection
- Two-way data binding
The ChangeDetectionStrategy.OnPush signifies that change detection is manual, and Angular checks for changes only when data-bound properties change or events occur.
How can you navigate to a different route using Angular's router?
- Using the ng-for directive
- Using the ng-model directive
- Using the ng-switch directive
- Using the router.navigate() method
You can navigate to a different route using Angular's router by using the router.navigate() method. This method allows you to programmatically navigate to a specified route.
To display a validation error message only when a form control is touched and invalid, you can use the expressions formControlName._____ and formControlName._____.
- dirty, pristine
- touched, pristine
- valid, dirty
- valid, invalid
To display a validation error message only when a form control is touched and invalid, you can use the expressions formControlName.touched and formControlName.pristine.
How does Angular Universal handle asynchronous operations like HTTP requests on the server side?
- Angular Universal doesn't handle asynchronous operations
- It blocks asynchronous operations during SSR
- It relies on client-side code to handle HTTP requests
- It uses server-side equivalents of Angular services
Angular Universal handles asynchronous operations like HTTP requests on the server side by using server-side equivalents of Angular services to make these requests.
In Angular testing, the ______ is used to create a controlled test environment around the directive.
- ComponentFixture
- HttpClientTestingModule
- NgModule
- TestBed
In Angular testing, the TestBed is used to create a controlled test environment around the directive, allowing you to configure and set up your tests.