Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Angularjs上传后,我如何访问csv文件的内容?_Angularjs_Csv - Fatal编程技术网

使用Angularjs上传后,我如何访问csv文件的内容?

使用Angularjs上传后,我如何访问csv文件的内容?,angularjs,csv,Angularjs,Csv,我已经写了一个非常简单的csv上传功能与角度文件上传。代码如下。我想我需要访问我上传的文件的内容。我需要获得csv的前几行以显示为文件预览。我能知道如何获取数据吗 app.controller('reporting.importexternaldata.controllers.main', [ '$scope', 'FileUploader', function ($scope, FileUploader) {

我已经写了一个非常简单的csv上传功能与角度文件上传。代码如下。我想我需要访问我上传的文件的内容。我需要获得csv的前几行以显示为文件预览。我能知道如何获取数据吗

  app.controller('reporting.importexternaldata.controllers.main', [
            '$scope',
        'FileUploader',
        function ($scope, FileUploader) {
            console.log('hahahahahaah');

            var uploader = $scope.uploader = new FileUploader({
                autoUpload: false,
                queueLimit: 1,
                filters: [{
                    name: 'csvOnly',
                    fn: function(item) {
                        console.log('in filter, file type (item.type) is: ' + item.type);
                        console.info('size: ' + item.size);
                        return true;
                    }
                }]
            });
       }
]);
html:


选择一个csv文件
队列长度:{{uploader.Queue.length}

{{item.file.name} {{item.\u file}

{{item.\u file}

中,我希望能够预览csv的前5行。但我不知道如何访问数据,我能知道如何访问吗

<div>
        <h2> Choose a csv file </h2>
        <input type="file" nv-file-select="" uploader="uploader" accept=".csv" />
    </div>
    <p>Queue length: {{ uploader.queue.length }}</p>
    <div ng-repeat="item in uploader.queue">
        <h2>{{ item.file.name }}</h2>
        <p>{{ item._file}}</p>
    </div>