Complete the code to bind the form submission to the handler method.
<form ([1])="onSubmit()"> <button type="submit">Submit</button> </form>
The ngSubmit event binds the form submission to the handler method in Angular.
Complete the code to prevent the default form submission behavior.
onSubmit(event: Event) {
event.[1]();
console.log('Form submitted');
}Calling preventDefault() stops the browser from performing the default form submission, allowing Angular to handle it.
Fix the error in the form control binding to correctly update the model.
<input type="text" [[1]]="name" (ngModelChange)="name=$event" />
Using [ngModel] binds the input to the component's property for two-way data binding.
Fill both blanks to create a reactive form with a control named 'email'.
this.form = new Form[1]({ email: new Form[2]('') });
FormGroup groups controls, and FormControl creates a single control.
Fill all three blanks to handle form submission and reset the form.
onSubmit() {
if (this.form.[1] === 'VALID') {
console.log(this.form.[2]);
this.form.[3]();
}
}Using status === 'VALID' to check validity, value gets the form data, and reset() clears the form.