2

AngularJS を使用してモーダル インスタンスにメール フォームを作成しました。これには、フィールド送信メール、受信者メール、件名、およびメール コンテンツが含まれています。フォームは、入力ボックスと ng-models を使用してデータを追跡します。ユーザーがこのフォームの送信ボタンを押すと、モデルによって収集されたすべての情報がサーバーに送信され、電子メールが送信されます。

現在、私は下書きボタンを持っています。ユーザーが下書きボタンを押すと、モデルで収集されたすべての情報をコントローラーに送信し、コントローラーはそれをサービスに送信して、ユーザーがモーダルを閉じることを決定した場合に情報を再入力できるようにしますインスタンスにして、後でメールを送信します。ただし、ユーザーが送信ボタンを押すと、このオブジェクトにすべての情報が含まれていますが、サーバーに送信する方法がわかりません。私は一般的にnode.jsとバックエンドに非常に慣れていないので、誰かが具体的な短い例を提供してくれれば、それから学ぶことができます.

npm を使用してインストールした nodemailer モジュールを使用したいと考えています。

ありがとう!

4

2 に答える 2

4

At the node side you can create a REST end point in order to recieve a POST request from the server for the form submission of email in the modal box. The REST end-point will look like this if you have an express server.

var express = require('express');
var router = express.Router();
var app = express();
app.post('/postEmail',function(req,res){
    //Your NodeMailer logic comes here
});

In the angular part, just like you have written a service, you can create an angular factory to invoke this REST end point.

For example:

myApp.factory('postEmailForm',['$http',function($http){
   return {
     postEmail: function(emailData,callback){
       $http.post("/postEmail/", emailData).success(callback);  
     }
   }
}]);

where myApp is your angular module, emailData is the emailForm data which you want to send to the server (it will be posted in the body of the request)

于 2014-09-02T03:41:56.663 に答える