0

i am using nodemailer and express...

i want to add text message and loading in front-end when form is inprogress to submit or not.

.ts

  sendMail(value) {    
    console.log('email sent');    
    // this.form.reset();
    const data = {
        to: 'xxxx@gmail.com',
        subject: this.name,
        txt:  'Email:' + this.email + 
              'Name:' + this.name + 
              'Message:' + this.message
    };
    return this.http.post('http://localhost:3000/api/mail/contact', data).subscribe(      
      data => console.log(data)      
    );
  }
  • `subscribe((data)=>{ //success },(error)=>{ //error })` – Empty Brain Jun 10 '18 at 08:40
  • Hi there, I think if I understand correctly you want to show a progress bar while processing right ? If so I suggest you look at this : https://material.angular.io/components/progress-bar/overview Hope it will help. Thanks, Jeremy – jérémy Darchy Jun 10 '18 at 08:58

1 Answers1

0

Try this:

 sendMail(value) {    
    console.log('email sent');    
    // this.form.reset();
    const data = {
        to: 'xxxx@gmail.com',
        subject: this.name,
        txt:  'Email:' + this.email + 
              'Name:' + this.name + 
              'Message:' + this.message
    };
    return this.http.post('http://localhost:3000/api/mail/contact', data).subscribe(      
      data => {alert(data)},Error => {alert("failed data")}    
    );
  }

You can also use bootstrap 4 alert(or something else): https://www.w3schools.com/bootstrap4/bootstrap_alerts.asp

לבני מלכה
  • 14,372
  • 2
  • 15
  • 38