我在firebase上托管了一个Angular 2应用程序.我想发一封联系表格作为电子邮件.理想情况下,我的解决方案将使用Nodejs,但我愿意使用能够正确完成工作的任何东西.以下是我的应用的细分.
这是我的表格:
<!-- contact-form.component.html -->
<form [formGroup]="formService.contactForm" (ngSubmit)="formService.onSubmitForm()">
<input type="text" formControlName="userFirstName">
<label>First Name</label>
<input type="text" formControlName="userLastName">
<label>Last Name</label>
<button type="submit">SUBMIT</button>
</form>Run Code Online (Sandbox Code Playgroud)
这是我的联系表单组件:
// contact-form.component.ts
import { Component } from '@angular/core';
import { ContactFormService } from './contact-form.service';
@Component({
selector: 'contact-form',
templateUrl: './contact-form.component.html',
styleUrls: ['./contact-content.component.css'],
providers: [ContactFormService]
})
export class ContactFormComponent {
constructor(private formService: ContactFormService) {
formService.buildForm();
}
}Run Code Online (Sandbox Code Playgroud)
这是我的联系表格服务:
// contact-form.service.ts
import { Injectable } from '@angular/core';
import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms';
@Injectable() …Run Code Online (Sandbox Code Playgroud)