how to read json file angular code example
Example 1: get data from json file angular
import variableName from '../../assets/fileName.json';
export class AppComponent {
public nameList:{field1:type, field2:type}[] = variableName;
}
declare module "*.json" {
const value: any;
export default value;
}
Example 2: read local json file in my angular project
How to Read Local JSON file in Angular
Step 1: Create an Angular application with Angular CLI. From terminal create a new angular app. ...
Step 2: Create JSON file with dummy data. Create any JSON file with any name, I have created a file countries. ...
Step 3: Import JSON file in the component. Update app. ...
Step 4: Update Component Template file. ...
Step 5: Run the app.