-4
我無法獲取JSON本地文件Angular HTTP服務。我有這些代碼:無法從JSON文件獲取數據
import {Injectable} from '@angular/core';
import {Http, Response} from "@angular/http";
import 'rxjs/add/operator/map'
@Injectable()
export class ApiService {
constructor(private http:Http) {
}
private coinsUrl:string = 'app/data/coins.json';
getMines() {
return this.http.get(this.coinsUrl).subscribe(
(res:Response)=> {
const sss = res.json();
console.log('sss', sss);
}
);
}
}
是的,它的工作!非常感謝 :) –