raj m
raj m

Reputation: 2023

Unable to load the config file in angular 2

I have folder structure like below.

src
  app
    resources
      config
         home.json
    services
      service.ts

I am trying to call the json file from config folder from service.ts like below

 return this._http.get('../../resources/config/home.json')

And I tried with couple more types. Unable to load the json file.

http://localhost:4200/resources/config/homeConfig.json 404 (Not Found) getting this error

Upvotes: 0

Views: 1544

Answers (1)

CharanRoot
CharanRoot

Reputation: 6325

if your using angular CLI than place inside

src/assets/home.json

access like this

 this.http.get('/assets/home.json')
                .subscribe(res => this.data = res.json());

Upvotes: 1

Related Questions