โ† All Angular Web Framework Flashcard Decks

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
  1. Which method on a FormGroup marks all descendant controls as touched?

    Answer: markAllAsTouched()

    `markAllAsTouched()` recursively marks every control in the group and its children as touched.

  2. What does the `updateOn` option set to `'blur'` do in a reactive form control?

    Answer: Triggers validation only when the field loses focus

    Setting `updateOn: 'blur'` defers value and validity updates until the user leaves the field.

  3. Which validator ensures a control's value matches a given regular expression?

    Answer: Validators.pattern()

    `Validators.pattern()` accepts a string or RegExp and validates the control value against it.

  4. How do you disable a specific FormControl inside a FormGroup without removing it?

    Answer: Both A and C are valid approaches

    You can call `control.disable()` at runtime or pass `{ disabled: true }` as the initial state object to `FormBuilder.control()`.

  5. What value does `formControl.value` return when the control is disabled?

    Answer: The current value is still returned

    A disabled control retains its value; `formControl.value` still returns the current value even when disabled.

  6. Which FormGroup method returns the raw value including disabled controls?

    Answer: getRawValue()

    `FormGroup.getRawValue()` returns the values of all controls including those that are disabled.

  7. What is the purpose of `AbstractControl.setErrors()` in reactive forms?

    Answer: Manually set validation errors on a control bypassing validators

    `setErrors()` lets you programmatically assign an error map to a control, useful for server-side validation results.