Post array to database from inputs

Viewed 1455

I have a litte problem and please some advices or help how I can solve this annoying problem. Question: How save values from multiple inputs in on array? In present code in database save only first input, and if I write something in first input in others is writing the same (I think the problem is in ng-model).

index.html

<div class="form-group">
  <form>
    <input type="text" ng-model="description" name="description" class="form-control" required>
    <input type="text" ng-model="description" name="description" class="form-control" required>
    <input type="text" ng-model="description" name="description" class="form-control" required>
    <button type="submit">Save</button>
  </form>
</div>

api.js

    router.post('/courses', function(req, res){
var course = new Product();
course.description  = req.body.description;
    course.save(function(err){
        if(err){
          console.log(err)
        } else {
            res.json({success:true, message:'saved!'});
        }
    })
});

service

    userFactory.createNewCourse = function(productData){
return $http.post('/api/courses', productData)

}

2 Answers
Related