如何创建能够在mongodb中存储数组的动态输入表单?

时间:2017-04-12 13:35:00

标签: angularjs mongodb mean-stack

这是我的猫鼬模式

var VoSchema =new Schema({
  name:{type: String, 
  required: true},
  price:{type: String},
  feeds : [Schema.Types.Mixed]
 }, {strict: false});

动态输入字段

 <div ng-repeat="item in inputs">
<div>
      <input ng-model="item.description">
    </div>
    <div>
      <input ng-model="item.qty">
    </div>
    <div>
      <input ng-model="item.cost"/>
    </div>
    <div >
      {{item.cost * item.qty}}
    </div>
  </div>
    <a class="btn btn-primary" href ng-click="addfield()" >[+]</a>
</div>

angularjs的控制器

$scope.submitx = function(inv){
      $scope.inv.feeds = $scope.inputs.item
        console.log(inv);

            PostBlog.createInvoice(inv).then(function(data){
          console.log(data);
        });
            $scope.inv= {};
      }

   $scope.inputs = [];
   $scope.addfield=function(){
    $scope.inputs.push({ qty:0, cost:0, description:"" })
 }

我想将数组中的数据推送到mongodb,我该如何实现? 请详细解释一下?如何在平均堆栈中使用动态表单。

0 个答案:

没有答案