Home > Enterprise >  Pass input data from Angular to NodeJS
Pass input data from Angular to NodeJS

Time:05-15

I am currently learning the MEAN stack and I'm wondering how I can pass data from the inputs in .html to my nodeJS app.js ?

Let's say I have a form :

register.component.html:

  <form>
    <input type="text" name="surname">
    <input type="text" name="name">
    <input type="text" name="username">
    <input type="password" name="password">
    <input type="submit" value="Register">
  </form>

And I would like that when it's submitted, it calls the register function :

resister.component.ts :

register(){
    this.http.post('http://localhost:3001/login/' // etc )

  }

So in my app.js :

app.post('/register', function(req, res){
    db.collection('users').insertOne({
        prenom : //inputs data,
        nom: //inputs data,
        email : //inputs data,
        password : //inputs data
    })
})

My question is : **How can I pass the data from the inputs in the .html TO the app.js ? **

Thank you very much, I'm sorry if this question feels noob to most of you, but I am learning !

  • Related