how to Create dynamic input form which is able to store the array in mongodb?

折月煮酒 提交于 2019-12-25 05:01:30

问题


This is my mongoose schema

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

Dynamic input field

 <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>

controller for 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:"" })
 }

I want to push the data in array to mongodb, how can i achieve this? please explain if possible in detail? how to use dynamic form in mean stack.

来源:https://stackoverflow.com/questions/43371130/how-to-create-dynamic-input-form-which-is-able-to-store-the-array-in-mongodb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!