# 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, contact-us.component.ts:

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

  selector: 'contact-us',
  templateUrl: './contact-us.component.html',
  styleUrls: ['./contact-us.component.css']
export class ContactUsComponent {

  public sendEmail(e: Event) {
    emailjs.sendForm('YOUR_SERVICE_ID', 'YOUR_TEMPLATE_ID', e.target as HTMLFormElement, 'YOUR_PUBLIC_KEY')
      .then((result: EmailJSResponseStatus) => {
      }, (error) => {

and 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