Answers for "show json data in html angularjs"

0

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;
}
Posted by: Guest on March-02-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language