Exploring Angular for the first time and attempting to set up a reactive form. Here's a glimpse of my HTML and TypeScript codes:
<form [formGroup]="signupForm" (ngSubmit)="onSubmit()">
<div class="form-group">
<label for="email">Email</label>
<input type="email" name="email" id="email" formControlName="email" class="form-control">
</div>
<button class="btn btn-primary" type="submit">Sign Up</button>
</form>
And now here is my TypeScript file snippet:
import { Component , OnInit} from '@angular/core';
import {FormControl, FormGroup, Validators} from '@angular/forms';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit{
title = 'app works!';
signupForm : FormGroup;
ngOnInit(){
this.signupForm = new FormGroup({
'email' : new FormControl('<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="91e5f4e2e5d1e5f4e2e5bff2fefc">[email protected]</a>')
});
// this.signupForm.valueChanges.subscribe(
// (value) => console.log(value)
// );
}
onSubmit(){
console.log(this.signupForm);
}
}
Despite thorough checks, I am unable to log anything on the console when clicking the button through the OnSubmit method. Can you please guide me on what might be going wrong?