The submit handler is short and does four things in order.
It stops the browser’s default form submission. It clears the previous failure. It lets the forms API validate and, on success, calls the action. And the action sends the model through the content service and records success or failure in signals. The test suite proves the three outcomes that matter. An invalid form sends no request. A valid form sends exactly one request containing the typed values. And a successful response replaces the form with a confirmation that is announced as a status.
Three further concerns belong to the server, and the front end’s job is to cooperate.
Duplicate submissions. A user who double-clicks Send should not create two records. The demo form handles it on the client in two ways: the button is disabled while a request is in flight, and the submit handler returns at once if one is already running. A test submits the form twice in quick succession and asserts that exactly one request was made. The server must still treat an identical request within a short window as one, because a client-side guard cannot stop a retried network request.
Spam. The cheap defenses work against the bulk of the traffic: a hidden field that humans leave empty and bots fill, a minimum time between page load and submission, and a rate limit per address on the server. Avoid challenge systems that send data to third parties unless you have accepted their privacy implications, which are the same kind you chose local models to avoid.
Privacy. Collect only the fields the purpose needs, state what happens to them next to the form, set a retention period on the server, and do not log message bodies. The message of a contact form often contains personal data and sometimes confidential data. An agent writing server code will log the request body for debugging, and the instruction file should forbid it.
Continue with the book
Explore the full treatment, worked examples, and exercises in Local AI Agents for Angular Teams.
Companion article for Local AI Agents for Angular Teams, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.
