Build an Angular contact form with Reactive Forms and HttpClient
An Angular contact form can post to FormThunder with HttpClient from a standalone component, using Reactive Forms for validation and a signal for status. No backend of your own is involved: FormThunder stores each submission and emails your verified address. You need provideHttpClient in your application config for the injection to work.
Updated
The Angular code
import { Component, inject, signal } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { FormBuilder, ReactiveFormsModule, Validators } from "@angular/forms";
@Component({
selector: "app-contact",
imports: [ReactiveFormsModule],
templateUrl: "./contact.component.html",
})
export class ContactComponent {
private http = inject(HttpClient);
status = signal<"idle" | "sending" | "sent" | "error">("idle");
form = inject(FormBuilder).nonNullable.group({
name: ["", Validators.required],
email: ["", [Validators.required, Validators.email]],
message: ["", Validators.required],
});
submit() {
if (this.form.invalid) return;
this.status.set("sending");
this.http
.post("https://formthunder.com/submit", { ...this.form.getRawValue(), access_key: "YOUR_ACCESS_KEY" })
.subscribe({
next: () => {
this.status.set("sent");
this.form.reset();
},
error: () => this.status.set("error"),
});
}
}<form [formGroup]="form" (ngSubmit)="submit()">
<label>Name <input formControlName="name" /></label>
<label>Email <input formControlName="email" type="email" /></label>
<label>Message <textarea formControlName="message"></textarea></label>
<button [disabled]="status() === 'sending'">Send</button>
@if (status() === 'sent') { <p role="status">Thanks, we got your message.</p> }
@if (status() === 'error') { <p role="alert">That didn't send. Please try again.</p> }
</form>import { provideHttpClient, withFetch } from "@angular/common/http";
export const appConfig = { providers: [provideHttpClient(withFetch())] };Replace YOUR_ACCESS_KEY with your free key. It's public by design, so it's safe in client code.
Notes for Angular
HttpClientsends objects as JSON and sets the content type itself, and it routes any 4xx or 5xx reply to theerrorcallback.- With no JavaScript, Angular renders nothing, so this form has no plain-post fallback unless you server-render with Angular SSR.
- Add a
botcheckcontrol styleddisplay: noneif you want the honeypot too. Leave it out of your validators.
Or have your AI add it
Connect the MCP server, then ask. The agent creates the form and writes the code for you, and it can send a real test when it's done.
Add a FormThunder contact form to this Angular site that emails hello@example.com. Send a test when you're done.Questions
Does this work with NgModules?
Yes. Remove imports from the component, then add ReactiveFormsModule to your module and provide HttpClient the same way.
Can I use template-driven forms?
Yes. ngModel with the same field names works. Post the model object to the same URL.
Get your Angular form sending
The free plan covers 250 submissions a month, with MCP, the CLI and the brand kit included.