为什么我不能以角度2获取文件?

时间:2016-09-10 15:12:39

标签: javascript http d3.js angular

基本上我正在尝试获取一个csv文件,以便稍后使用d3解析它。 我创建了一个特殊的组件来获取数据,并将其传递给另一个组件来解析它。

fetch-data组件如下:

hgetall articles

这是d3代码应该去的另一个组件:

import {Component, Injectable} from '@angular/core';
import {Http, Response, Headers, RequestOptions, HttpModule} from "@angular/http";
import {Observable} from 'rxjs/Rx';

@Component({
  selector: 'app-fetch-data',
  templateUrl: './fetch-data.component.html',
  styleUrls: ['./fetch-data.component.css'],
  providers: [HttpModule]
})

@Injectable()
export class FetchDataComponent {

  constructor(private http: Http) {
  }

  getCsv(): Observable<any> {
    return this.http.get('app/districts_data/data.csv').map((res: Response) => res);

  }

}

但似乎没有任何东西。我哪里出错了?

0 个答案:

没有答案