angularjs - How to update JSON file with Angular and Node? -


i'm totally new in backend, i'm trying data form , push json file. i've tried find solution, in situation examples or separated or mongodb, learning angular , node.
have:

  1. in front-end have submit function says:
    "failed load resource: server responded status of 405 (method not allowed) http://127.0.0.1:8080/form/json/data.json " . of course.

        $scope.submit = function(person) {          $http.post('json/data.json', $scope.data).then(function(){             $scope.msg = 'saved';         });     }; 
  2. back-end. i'm new in node i've said, that's why server this:
var http = require('http'); var express = require('express'); var server = express(); server.use(express.static(__dirname)); var port = 8080; server.listen(port, function() {     console.log(port); }) 

as understand, need post request @ first angular controller server , server post request json file? please can explain steps how , simple code great.

with current code, express doesn't know function call when receives request. need create route each request sent server:

    server.post('/json/data ', function (req, res) {                /// req data here, send res ///    }); 

more information can found here: http://expressjs.com/guide/routing.html


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -