Forms Questions with Answers

18 practice questions on Forms (Angular) with answers and step-by-step solutions. Try 10 samples below, then practise all 18 free in the AptiNest app.

Sample questions

Question 1Easy

Which two main approaches does Angular provide for building forms?

  1. Static and dynamic forms
  2. Template-driven and reactive forms
  3. Imperative and declarative modules
  4. Client and server forms

Answer: B. Template-driven and reactive forms

Explanation

Template-driven forms rely on directives in the template; reactive forms are built in code with FormControl and FormGroup.

Step-by-step solution

  1. Angular uses templates to build forms with directives.
  2. Reactive forms are created using classes like FormControl.
  3. Template-driven forms use HTML for form logic.
  4. These two methods are called Template-driven and reactive forms.
  5. Final answer: B (Template-driven and reactive forms).

Why the other options are wrong

  • A. Static and dynamic forms are not Angular's two approaches; the two are template-driven and reactive.
  • C. Imperative and declarative modules are not Angular's form approaches; forms use template-driven or reactive styles.
  • D. Client and server forms are not an Angular division; the two approaches are template-driven and reactive.

Question 2Easy

What is two-way binding syntax in templates?

  1. (ngModel)="name" which only listens for events
  2. [(ngModel)]="name"
  3. [ngModel]:"name" with a colon
  4. {{ngModel}}=name as interpolation

Answer: B. [(ngModel)]="name"

Explanation

The banana-in-a-box combines property and event binding.

Step-by-step solution

  1. [()] combines both.

Why the other options are wrong

  • A. Parentheses only listen to events; two-way needs brackets as well.
  • C. A colon is not valid binding syntax; use brackets around ngModel.
  • D. Curly braces interpolate text; they do not create a two-way binding.

Question 3Easy

Which module provides ngModel in template-driven forms?

  1. ReactiveFormsModule
  2. HttpClientModule
  3. RouterModule
  4. FormsModule

Answer: D. FormsModule

Explanation

FormsModule enables ngModel and ngForm.

Step-by-step solution

  1. Template-driven needs FormsModule.

Why the other options are wrong

  • A. Reactive forms use ReactiveFormsModule, not ngModel in templates.
  • B. HttpClientModule handles HTTP calls, not template-driven form binding.
  • C. RouterModule provides routing directives, not ngModel.

Question 4Easy

Which property indicates that a form control has passed all validators?

  1. touched
  2. pristine
  3. dirty
  4. valid

Answer: D. valid

Explanation

control.valid is true when there are no errors.

Step-by-step solution

  1. Validity.

Why the other options are wrong

  • A. touched means the control was blurred, not that it passed validators.
  • B. pristine means the value is unchanged, not the validation status.
  • C. dirty means the value changed, not that validation passed.

Question 5Medium

Which validator ensures a reactive form control is not empty?

  1. Validators.min
  2. Validators.nullValidator
  3. Validators.pattern only
  4. Validators.required

Answer: D. Validators.required

Explanation

Validators.required flags empty values as invalid.

Step-by-step solution

  1. Validators.required checks if a value is present in the form control.
  2. It marks the field as invalid if the input is empty or null.
  3. This validator is specifically used to ensure required fields are not left blank.
  4. Other validators like min or pattern do not handle emptiness directly.
  5. The correct answer is Validators.required.

Why the other options are wrong

  • A. Validators.min checks that a number is at least a minimum; it does not check for an empty value.
  • B. Validators.nullValidator is a no-op that always passes, so it does not enforce a value.
  • C. Validators.pattern checks text against a regex and usually passes empty values, so it does not enforce a value.

Tip: Use Validators.required to prevent empty inputs in reactive forms.

Question 6Medium

Which validator makes a control required?

  1. Validators.must
  2. Validators.notNull
  3. Validators.present
  4. Validators.required

Answer: D. Validators.required

Explanation

Built-in validators live in Validators.

Step-by-step solution

  1. Name it.

Why the other options are wrong

  • A. Validators.must does not exist in Angular's validator set.
  • B. notNull is not an Angular validator; required is the one used.
  • C. Validators.present is not a real Angular validator.

Question 7Medium

What does form.valid indicate for a FormGroup?

  1. At least one control has been touched by the user
  2. All of its controls are valid
  3. The form has already been submitted once
  4. The form has no controls registered in it yet

Answer: B. All of its controls are valid

Explanation

A group is valid only when every child control has passed validation.

Step-by-step solution

  1. FormGroup's valid property checks all its controls.
  2. Each control must be valid for the form to be valid.
  3. If any control is invalid, form.valid becomes false.
  4. So form.valid means all controls are valid.
  5. Final answer: All of its controls are valid.

Why the other options are wrong

  • A. Touched means the user focused and left a field; form.valid does not depend on that.
  • C. Submitting the form does not decide validity; form.valid only reflects the status of the controls.
  • D. An empty FormGroup is still valid; having no controls does not make form.valid mean something else.

Tip: Remember: FormGroup is only valid if every control inside it is valid.

Question 8Medium

What do the CSS classes ng-touched and ng-dirty indicate?

  1. touched: the control was blurred; dirty: its value was changed
  2. touched: the value passed validation; dirty: the value failed validation
  3. touched: disabled; dirty: pristine
  4. They are the same

Answer: A. touched: the control was blurred; dirty: its value was changed

Explanation

Angular adds state classes to controls.

Step-by-step solution

  1. Touched is about focus lost.
  2. Dirty is about value change.

Why the other options are wrong

  • B. Touched and dirty describe user interaction, not validation results.
  • C. Touched and dirty do not mean disabled or pristine.
  • D. They describe different states, so they are not the same thing.

Question 9Hard

What does updateOn: 'blur' change?

  1. Validation and value updates occur when the control loses focus rather than on every keystroke
  2. Disables validation for the control so that no errors are calculated at all, even when the form is submitted
  3. Updates only when the form is submitted
  4. Applies a built-in 500 ms debounce

Answer: A. Validation and value updates occur when the control loses focus rather than on every keystroke

Explanation

updateOn takes change, blur or submit.

Step-by-step solution

  1. Option on control.

Why the other options are wrong

  • B. updateOn blur still validates; it only changes when updates happen.
  • C. Blur updates the value on focus loss, not only at form submit.
  • D. updateOn blur has no built-in debounce; it waits for focus loss.

Question 10Hard

A custom validator for a FormControl should return what when the value is valid?

  1. true
  2. an empty string
  3. undefined error object
  4. null

Answer: D. null

Explanation

Validators return an error map or null for valid.

Step-by-step solution

  1. Valid -> null.

Why the other options are wrong

  • A. Booleans are not used.
  • B. Strings are not the contract.
  • C. Error object means invalid.

Practise all 18 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Angular topics · All topics