2016-08-03 43 views
1

我有$ scope.todos Node.js的服務器,並在我的控制器代碼提交即

$scope.submitChanges = function() { 
    var todos = $resource("/todo"); 

    //code goes here for sending variable 
} 

我想將它發送到節點。 JS,這需要它:

router.post("/",function(req, res) { 
    var collection = db.get("todo"); 
    collection.insert({ /* here comes the data to insert */ }, function(err, todos) { 
     if(err) throw err; 
     res.json(todos); 
    }) 
}) 

回答

0
var CreditCard = $resource('/todos/:Id', 
{userId:123, Id:'@id'}, { 
charge: {method:'POST', params:{charge:true}} 
}); 
+0

我們不能做到這一點使用$資源,而不是使用$ HTTP。謝謝.. – SaiUnique

+0

是的,你必須這樣做使用$資源 –

+0

檢查更新的答案 –