with angularJS i have got a datafile, where i communicate with the database.
Therefore i want to send the data to the i got from the frontend to send it to the packend, but somehow this is now working. can you please help me.
app.get('/api/data/:id', function (req, res) {
res.json({...});
});
app.post('/api/data/', function (req, res) {
res.json({
success: true
})
});
for the get and delete functions this works fine, but I have no idea how to make the post and put function and how to get the data in there.
Here what i do on the client
add:function (data) {
location = '/api/data/';
$http.put(location, merchant, successCb).
success(function(data, status, headers, config) {
console.log(arguments);
successCb(data);
}).
error(function(data, status, headers, config) {
console.log('Error:' + arguments);
});
},
can someone please help me how to write that on the server and client. (i get the right data on the client and its a simple javascript object.
you must use $resource which is the correct way for communicating with restful server side data source...
angularjs has very nice examples about $resource here: http://docs.angularjs.org/api/ngResource .$resource
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.