communication between express + angularJS

By : Safari

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) {
});'/api/data/', function (req, res) {
        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) {
                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.

By : Safari


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:$resource

By : CocoOS

This video can help you solving your question :)
By: admin