Angular 6 - Load JSON from local

前端 未结 9 2547
南笙
南笙 2020-12-14 04:26

I am trying to load a local JSONfile of two ways.

This is my json file:

{
  \"imgsesion\": \"fa_closesesion.png\",
  \"texthome\": \"volver a la home         


        
9条回答
  •  感动是毒
    2020-12-14 04:50

    Step 1: Open tsconfig.json add following lines in compilerOptions:

    "resolveJsonModule": true,
    "esModuleInterop": true
    

    Step 2: import json using following code:

    import homeData from './data.json';
    

    Note: This code is tested with Angular 9

提交回复
热议问题