0
私は私が角度のjsパスcsvファイルの内容は、jsのノードとモンゴDBに挿入するためにノードのjsに解析する
app.get('/index.html', function(req, res) {
res.sendFile(__dirname + '/index.html');
});
app.post('/add_event', function(req, res, next) {
console.log("Node JS File1 :" +req);
var finalData = req.body.test;//value is undefined
console.log("Node JS File : " + finalData);//value is undefined
のindex.html
からcsvファイルの内容を取得しています。このReadCSV.jsを持っていますvar myapp = angular.module('myapp', []);
myapp.controller('MainCtrl', function ($scope,$http) {
$scope.showContent = function($fileContent){
$scope.content = $fileContent;
var test= $fileContent;
alert(test);
};
$scope.submit = function(test){
//
$http.post('/add_event', $fileContent)
.success(function(){
console.log("here" +$fileContent);
});
}
<body ng-controller="MainCtrl">
<form ng-submit="submit()">
<div class="test">
<div class="panel-heading">
<h3 class="panel-header">Upload Events</h3>
</div>
<input class="btn btn-primary" type="file" on-read-
file="showContent($fileContent)"/></br>
<button class="btn btn-primary btn-block" ng-click="processData(content)"
type="submit">
Upload File
</button>
</div>
</form>
<div class="test2">
{{content}}
</div>
値が未定義です。 角度jsからノードjsにcsvコンテンツを渡して、それを解析してmongodbに挿入できるようにする方法。