You are tasked with building a form that needs to validate the password and confirm password fields are the same. How would you approach implementing this validation?
- Built-in Angular validation
- None of the above
- Perform validation in the template
- Use a custom validator function
To validate that the password and confirm password fields are the same, you should use a custom validator function to implement custom validation logic.
In reactive forms, the _____ operator is often used to transform and process form values before submission.
- map()
- reset()
- submit()
- updateValueAndValidity()
In reactive forms, the map() operator is often used to transform and process form values before submission, typically in combination with RxJS.
How can you bind an image source dynamically in an Angular template?
- (img) element binding
- [imageSrc] property binding
- [src] attribute binding
- {{ imgSrc }}
In an Angular template, you can bind an image source dynamically using the [src] attribute binding to set the image source from a variable.
Which NgRx library function is used to define actions in a state management setup?
- createAction
- createEffect
- createFeatureSelector
- createReducer
In NgRx, the function used to define actions in a state management setup is createAction. Actions are a crucial part of state management, representing events that can change the application's state.
To restrict access to child routes based on user roles, you can implement a custom _____ Guard.
- authentication
- canActivate
- canDeactivate
- role
To restrict access based on user roles, you can implement a custom canActivate Guard. A Guard like this checks whether the user has the required role to access the route.
Which directive is used to create a form control in template-driven forms?
- FormControl
- FormGroup
- ngForm
- ngModel
In template-driven forms, the ngModel directive is used to create a form control. It binds form elements like input fields and selects to properties in the component class, allowing two-way data binding.
To wait for Angular to finish rendering before executing the next command in a Protractor test, you can use _____.
- browser.pause()
- browser.sleep()
- browser.waitForAngular()
- browser.waitForRender()
To wait for Angular rendering in a Protractor test, you can use browser.waitForAngular(), which ensures synchronization with Angular.
How can you create a custom operator in RxJS?
- Create a new Observable class
- Extend the Observable class
- Implement a Promise-based approach
- Use the pipe method
To create a custom operator in RxJS, you should use the pipe method to compose existing operators and functions to form your custom operator.
For a directive to be used across multiple modules, it needs to be declared in a shared module and exported using the ________ array.
- declarations
- exports
- imports
- providers
To use a directive across multiple modules, it should be declared in a shared module and exported using the exports array.
You are developing a real-time dashboard that needs to display data from multiple API endpoints. Which RxJS operators can help you effectively combine and manage the data from these endpoints?
- filter and combineLatest
- map and catchError
- mergeMap and forkJoin
- reduce and debounceTime
In this scenario, you can use mergeMap to merge and flatten multiple observables, and forkJoin to wait for all observables to complete and return their results. This combination is effective for handling data from multiple API endpoints in a real-time dashboard.