Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
La forma angular no envía datos dinámicamente

Tengo un problema al tratar de capturar dinámicamente el texto y enviarlo a mi correo electrónico. Funciona cuando se escribe manualmente en TS onSendEmail. Estoy usando un servidor de alojamiento de correo electrónico gratuito y la carpeta de activos tiene los archivos necesarios

Código HTML

 <form (ngSubmit)="onSendEmail(addEmailForm)" #addEmailForm ="ngForm"> <fieldset> <legend>Contact us</legend> <label>Your name</label> <br> <input ngModel name="name" type="text" placeholder="Your name" size="20" required ><br> <label>E-mail address</label> <br> <input ngModel name="email" type="text" placeholder="example@example.com" size="20" required><br> <label>Subject</label> <br> <input ngModel name="subject" type="text" size="20"><br> <label>Body</label> <br> <textarea ngModel name="body" type="text" cols="40" rows="6" required></textarea><br> <button [disabled]="addEmailForm.invalid" >Send</button> </fieldset> </form>

Código mecanografiado

 import { HttpClient } from '@angular/common/http'; import { Component, OnInit, AfterViewInit } from '@angular/core'; import { NgForm } from '@angular/forms'; declare let Email: any; import 'src/assets/smtp.js'; // available in assets folder @Component({ selector: 'app-map', templateUrl: './shops.component.html', styleUrls: ['./shops.component.css'] }) export class ShopsComponent implements OnInit, AfterViewInit { constructor(private http: HttpClient) { } ngOnInit(): void { } body: any subject: any; email: any; name: any; onSendEmail(addEmailForm: NgForm) { Email.send({ Host : "smtp.elasticemail.com", Username : "myemail@hotmail.com", Password : "mypassword", To : 'mysecondemail@hotmail.com', Name: this.name, From : this.email, // when I write these manually the email gets sent Subject : this.subject, Body : this.body, }).then( (message: any) => alert("E-mail sent, thank you.") ); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Para obtener datos completos de su de Debe usar:

 onSendEmail(addEmailForm: NgForm) { let data = addEmailForm.value; //... }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!