编码对我来说是新的,我尝试使用Papaparse和AngularJS。我的代码如下。我似乎想念一些事情,希望有人能帮助我。
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/4.1.2/papaparse.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="mainController">
<p>{{test}}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.service('papa', function() {
Papa.parse("test.csv", {
download: true,
header: true,
dynamicTyping: true,
complete: function(results) {
console.log(results.data);
}
})
});
app.controller('mainController', function($scope, papa) {
$scope.test = papa;
console.log($scope.test);
});
</script>
</body>
</html>
&#13;