read local json file in my angular project

Solutions on MaxInterview for read local json file in my angular project by the best coders in the world

showing results for - "read local json file in my angular project"
Jawad
14 Jan 2019
1/*--IN THE TS OF THE COMPONENT--*/
2//In imports section
3import variableName from '../../assets/fileName.json';
4
5//In the class part of the same file
6export class AppComponent {
7  //This variable will have all the values
8  public nameList:{field1:type, field2:type}[] = variableName;
9}
10
11/*--IN A NEW TS FILE--*/
12//Create another js file in the app folder with
13declare module "*.json" {
14	const value: any;
15	export default value;
16}
Matthieu
18 Nov 2018
1How to Read Local JSON file in Angular
2Step 1: Create an Angular application with Angular CLI. From terminal create a new angular app. ...
3Step 2: Create JSON file with dummy data. Create any JSON file with any name, I have created a file countries. ...
4Step 3: Import JSON file in the component. Update app. ...
5Step 4: Update Component Template file. ...
6Step 5: Run the app.
similar questions
queries leading to this page
read local json file in my angular project