小编TYM*_*YMG的帖子

Angular 6:HttpClient获取JSON文件404错误

使用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)

angular angular-httpclient angular6

2
推荐指数
1
解决办法
5671
查看次数

标签 统计

angular ×1

angular-httpclient ×1

angular6 ×1