【发布时间】:2019-12-08 02:39:53
【问题描述】:
我在后端写了这个方法 router.put('/validateAccount', function (req, res) {//这里是实现nodemailer的代码}
我想在我的 angular Front-end 中调用它所以我在 inscription.service.ts 中写了一个函数
ValidateAccount(user){
// var headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers });
return this.http.post('http://localhost:3333/api/validateAccount',user) .map((response: Response) => response.json(),err =>err)
}
我想在 inscription.component.ts 中使用它,在同一个函数中从同一个服务调用 AddUser() 方法
register(event) {
event.preventDefault();
let newUser = {
type:"particulier",
login:this.login,
email: this.email,
tele: this.tele,
pass: this.pass,
confpass: this.confpass
}
this.inscriptionService.AddUser(newUser).subscribe(res => {
console.log(res)
this.formSubmitAttempt = true;
this._router.navigate(['/inscription']);
},err=>{
// console.log(err)
// this.message = "email existe déjà"
// this.showMessage = true;
alert("email existe deja");
})
}
这样可以吗,不然怎么办
【问题讨论】:
-
所以你想在 addUser 之前调用 validate?
-
是的!确切地。所以我可以向订阅者发送验证电子邮件
标签: node.js angular mean nodemailer