使用HTTP客户端,我将检索一个JSON文件,该文件位于assets使用CLI生成的Angular 6 App中的目录中。虽然我知道有几个与此主题相关的问题(和答案),但是在我的情况下没有一个有效。
下面是我的文件结构:
具体来说,我正在尝试检索 us-all-all.geo.json
angular.json
"projects": {
"ng-ngrx-highcharts-example": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/ng-ngrx-highcharts-example",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src",
"src/assets",
"src/favicon.ico",
"src/assets/us-all-all.geo.json"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
Run Code Online (Sandbox Code Playgroud)
map-data.service.ts
import { Injectable } from '@angular/core';
import { Observable, of, from } from 'rxjs';
import * as $ from 'jquery';
import { …Run Code Online (Sandbox Code Playgroud)