Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to add JSON service to Angular2 #3172


User avatar
0
btg created

I am trying to retrieve information from a JSON file and display it as elements on a dashboard. Do I need to add an entry in

/app/shared/service-proxies/service-proxies.ts

for a new Injectable service, then add it to the component.ts that will display it in the component.html file? Is there a better way to do this?


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    If you are trying to read a json file from server, you can do it like we do here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/angular/src/AppPreBootstrap.ts#L31">https://github.com/aspnetzero/aspnet-ze ... rap.ts#L31</a>.

    You don't need to modify service proxies, even if you do, if there is no server side matching code, when you refresh using refresh.bat under nswag folder, you change will be gone.

    So, you can do it using above approach.

    Thanks.