Angular 6 - Load JSON from local

前端 未结 9 2526
南笙
南笙 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:43

    This happens because you are requesting a JSON file asynchronously, you can handle with safe navigation operator or using ngIf,

    
    

    or simply import the JSON file in your component and assign sampleJSON.

    import "sampleJSON" from "./sampleJSON"
    

提交回复
热议问题