Reactive Forms & Validation Flashcards
7 cards from real Angular Web Framework practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Reactive Forms & Validation flashcards as text
Which operator is commonly used to debounce a reactive form's `valueChanges` observable before making an HTTP call?
Answer: debounceTime()
`debounceTime()` waits for a specified quiet period after the last emission before forwarding the value, reducing unnecessary API calls.
In a cross-field validator, where should you attach the validator to validate that `password` and `confirmPassword` match?
Answer: On the parent FormGroup
Cross-field validators are attached to the FormGroup so they have access to all sibling controls.
What is the return type of a valid (passing) custom validator function?
Answer: null
A validator must return `null` when the control is valid; any non-null object signals an error.
Which FormArray method removes the control at a given index?
Answer: removeAt(index)
`FormArray.removeAt(index)` removes the control at the specified position and updates the array's validity.
How does Angular determine whether an async validator is still pending?
Answer: The control's status is 'PENDING'
While async validators are running, the control's `status` property is set to `'PENDING'`.
What does calling `FormGroup.reset()` without arguments do to control values?
Answer: Sets all control values to null
Calling `reset()` with no argument sets every control's value to `null` and resets touched/dirty/pristine state.
Which property would you check to know if a reactive form control has been changed by the user but not yet submitted?
Answer: dirty
`dirty` is `true` when the user has changed the control's value since it was last reset.