angular 11 read json file from assets code example
Example: get data from json file angular
/*--IN THE TS OF THE COMPONENT--*/
//In imports section
import variableName from '../../assets/fileName.json';
//In the class part of the same file
export class AppComponent {
//This variable will have all the values
public nameList:{field1:type, field2:type}[] = variableName;
}
/*--IN A NEW TS FILE--*/
//Create another js file in the app folder with
declare module "*.json" {
const value: any;
export default value;
}