0

I am struggling to access a local JSON file in my component file via JavaScript. In Angular 1, I would just make a service and inject it into my controller, but am lost with Angular 2.

Racil Hilan
  • 24,690
  • 13
  • 50
  • 55
user1876246
  • 1,219
  • 5
  • 18
  • 33

1 Answers1

0

If you want to get data from local JSON file. First You need to get json data into varible using HttpClient

Angular 2 HttpClient Official Docs

then JSON data available to print Data

if your name data in jsonDATA variable then

<ul>
<li *ngFor="let newData of jsonData">
{{newData.name}}
</li>
</ul>

If you get any error after this, then please ask with your sample error code

Thanks

Shubham Kandiyal
  • 340
  • 2
  • 13