输入值在ng-repeat中没有变化

时间:2016-03-02 12:07:34

标签: javascript html angularjs node.js multer

我正在尝试使用multer上传图片。上传部分没问题,但我也想将对象名称/ id传递给index.js,因为我想更新产品模型中的imageURL值。

这是html ::

<table class="table table-striped">
    <thead>
        <tr>
            <th>#</th>
            <th>Name</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="product in products">
            <td>{{$index + 1}}</td>
            <td>{{product.name}}</td>
            <td>
                <form action="/pictures/upload" method="POST"     
                      enctype="multipart/form-data"  
                      style="display:inline;">

                    <input type="hidden" name="pName" ng-value="product.name">
                    <input id="fileSelector" type="file" style="display:none;" name="avatar">
                    <input id="btnSubmit" type="submit" style="display:none;">

                </form>
            </td>
        </tr>
    </tbody>
</table>

此表格位于表格内。但当我检查req.body.pName的值时 ,它给出了表格中第一个产品的价值,无论图片上传的行如何。

这里是index.js:

router.post('/pictures/upload', function (req, res, next) {
  uploading(req, res, function(err){
    if (err) {
      console.log("Error Occured!");
      return;
    }
      console.log("Saved Successfully !!!");
      console.log(req.body.pName);
  });
   res.status(204).end();
});

我做错了什么?任何帮助,将不胜感激。

请告知您是否认为可能以其他任何方式完成(希望不是那么复杂!)。

0 个答案:

没有答案