Ich habe diese ReadCSV.js wo i CSV-Datei Inhalt aus Winkel js am AbrufenPass CSV-Datei-Inhalt aus Winkel js js dem Knoten und Knoten in js parsen in mongo db einzufügen
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
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>
Ich bekomme Wert als undefiniert. Wie übergebe ich den csv-Inhalt von angular js an node js und analysiere es, damit ich in mongodb einfügen kann.