javascript - Angular4: how do access local json? -


in angular2 have folder /data/ , json file there , access @ localhost:4200/data/something.json.

this no longer possible in angular4.

any ideea how work?

you can use code

@injectable() export class appservices{      constructor(private http: http) {          var obj;          this.getjson().subscribe(data => obj=data, error => console.log(error));     }      public getjson(): observable<any> {          return this.http.get("./file.json")                          .map((res:any) => res.json())                          .catch((error:any) => console.log(error));       } } 

here file.json local json file.

see here also

also see changlog of angular-cli path


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -