Search code examples
angularangular-routingangular-routerangular8

Deliver json file via Angular routing


I need to deliver a static json file in my angular application for an external provider to use.

for example: http://angular-app-url:4200/app-test.json

When I do routing, it is always for a component or its just redirect to another path. how can I achieve this to deliver this json file?


Solution

  • In your angular.json file under options look for the assets entry and add the following:

    "assets": [
        "src/path_to_your_file/app-test.json",
    ]