Answers for "json file in angular 8"

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
0

angular json and cli json file

npm install -g @angular/cli

npm install @angular/cli
Posted by: Guest on October-24-2020

Code answers related to "json file in angular 8"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language