# Angular

Angular (opens new window) is a JavaScript framework for building web applications and apps in JavaScript, html, and TypeScript. EmailJS works with Angular out of the box.

Below we give an example for the contact form components.

The contact-us.component.ts:

import { Component } from '@angular/core';
import emailjs, { type EmailJSResponseStatus } from '@emailjs/browser';

  selector: 'contact-us',
  templateUrl: './contact-us.component.html',
  styleUrls: ['./contact-us.component.css'],
export class ContactUsComponent {
  public sendEmail(e: Event) {

      .sendForm('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', e.target as HTMLFormElement, {
        publicKey: 'YOUR_PUBLIC_KEY',
        () => {
        (error) => {
          console.log('FAILED...', (error as EmailJSResponseStatus).text);

And the template:

<form class="contact-form" (submit)="sendEmail($event)">
  <input type="text" name="user_name">
  <input type="email" name="user_email">
  <textarea name="message"></textarea>
  <input type="submit" value="Send">

If you use FormsModule, then you should use the ngSubmit listener without preventDefault method