Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 如何在无模式mongoose中添加对象数组?_Angularjs_Arrays_Mongodb_Mongoose - Fatal编程技术网

Angularjs 如何在无模式mongoose中添加对象数组?

Angularjs 如何在无模式mongoose中添加对象数组?,angularjs,arrays,mongodb,mongoose,Angularjs,Arrays,Mongodb,Mongoose,api.js,将数据发布到服务器 如何在数组中保存对象数组 ** //得救了 })) angularjs控制器 $scope.addProduct=function(){ } 请查看此代码并帮助我!挣扎了几个星期。有一个像[“name”:carrot,“price”:24,“:”等]这样的对象数组。那些陷入困境的人参考这个数组,而不是使用这个方法 $scope.submitx = function(inv, item){ console.log(inv); v

api.js,将数据发布到服务器

如何在数组中保存对象数组

**

//得救了

}))

angularjs控制器

$scope.addProduct=function(){

}


请查看此代码并帮助我!挣扎了几个星期。有一个像[“name”:carrot,“price”:24,“:”等]这样的对象数组。

那些陷入困境的人参考这个数组,而不是使用这个方法

$scope.submitx = function(inv, item){

        console.log(inv);

        var object = {
      name:inv.name,
      fname:items.fname,
     totalValue:       0
  }
            PostBlog.createInvoice(objects).then(function(data){
          console.log(data);
        });
            $scope.objects= {};
      }
router.post('/invoices',函数(req,res){//通过从
var发票=新发票();
对于(变量i=0;i
你的问题不是很简洁,所以不难理解你在这里要做什么。如果我理解正确,你想在
项中存储对象,但你不知道这些项的确切字段。在这种情况下,将
项定义为
项:[]
,而不是定义类似
项:[item]
。现在,您可以将任何对象推入
项中。
router.post('/objectss', function(req, res){ 

  var object= new Object(); **
    object.items.push({firstName: req.body.fname, lastName:      req.body.lname});
    object.name = req.body.name;
        object.save(function (err) {
        if(err) throw err;

        res.json({success: true, message:'allahuakbar'});

    });
  $scope.items.push({
     fname: $scope.item.fname,
     lname: $scope.item.lname

  });

  $scope.item = {};
$scope.submitx = function(inv, item){

        console.log(inv);

        var object = {
      name:inv.name,
      fname:items.fname,
     totalValue:       0
  }
            PostBlog.createInvoice(objects).then(function(data){
          console.log(data);
        });
            $scope.objects= {};
      }
 router.post('/invoices', function(req, res){ //by making route in from              


    var invoice = new Invoice();

       for (var i = 0; i < req.body.length; i++) {

 invoice.items.push({name:req.body.fname[i].fname});
  } 
   invoice.name = req.body.name;
    //invoice.items.insertMany(items, function(error, next) {
        invoice.save(function (err) {
        if(err) throw err;

        res.json({success: true, message:'allahuakbar'});

    });



  // saved!

 });