0
0
Angularframework~20 mins

Reactive forms vs template forms decision in Angular - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Reactive Forms Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
When to prefer reactive forms over template-driven forms?
Which scenario best justifies choosing reactive forms instead of template-driven forms in Angular?
AWhen you need fine-grained control over form state and complex validation logic
BWhen you want to use two-way data binding with ngModel for quick setup
CWhen you want to write less TypeScript code and rely mostly on HTML
DWhen the form is simple with few fields and minimal validation
Attempts:
2 left
💡 Hint
Think about which form type offers more programmatic control and scalability.
component_behavior
intermediate
2:00remaining
Behavior difference in form value updates
In Angular, which form type updates the form model immediately on each input change?
AReactive forms update the model only after form submission
BReactive forms update the model immediately on input change
CTemplate-driven forms update the model immediately on input change
DBoth reactive and template-driven forms update the model only after blur event
Attempts:
2 left
💡 Hint
Consider which form type uses observables to track changes instantly.
📝 Syntax
advanced
2:30remaining
Correct way to create a reactive form group
Which code snippet correctly creates a reactive form group with a required 'email' field in Angular?
Angular
import { FormGroup, FormControl, Validators } from '@angular/forms';

// Choose the correct initialization
Athis.form = new FormGroup({ email: new FormControl('', Validators.required()) });
Bthis.form = new FormGroup({ email: new FormControl('', Validators.required) });
Cthis.form = new FormGroup({ email: new FormControl('', { Validators.required }) });
Dthis.form = new FormGroup({ email: new FormControl('', [Validators.required]) });
Attempts:
2 left
💡 Hint
Validators.required is a function reference and should be passed inside an array for multiple validators.
🔧 Debug
advanced
2:30remaining
Why does this reactive form not validate the email field?
Given this reactive form setup, why does the email field not show validation errors when empty? this.form = new FormGroup({ email: new FormControl('', Validators.required) });
AValidators.required should be passed inside an array, like [Validators.required]
BThe form control is missing an initial value, so validation won't trigger
CThe form control is missing a call to markAsTouched() to trigger validation display
DThe form control is missing the updateOn option set to 'blur'
Attempts:
2 left
💡 Hint
Think about when Angular shows validation errors in the UI.
lifecycle
expert
3:00remaining
Reactive form valueChanges subscription behavior
What happens if you subscribe to a reactive form's valueChanges observable inside ngOnInit without unsubscribing on component destroy?
AMemory leaks can occur because the subscription stays active after component destruction
BThe subscription will throw an error when the component is destroyed
CNo issues occur; Angular automatically cleans up subscriptions
DThe subscription will only emit once and then complete automatically
Attempts:
2 left
💡 Hint
Consider Angular's behavior with observables and component lifecycle.