Answers for "how import json file in .ts angular"

0

import file json angular 12

import { Component } from '@angular/core';
import EmployeesJson from '../assets/employees.json';

interface EMPLOYEE {
  id: number;
  name: string;
  username: string;
  email: string;
  phone: string;
  website: string;
}

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'Import JSON Data from Assets Folder';

  Employees: EMPLOYEE[] = EmployeesJson;

  constructor(){
    console.log(this.Employees);
  }
}Copy
Posted by: Guest on January-11-2022
-2

how to import a json string from a file in typescript

import {default as a} from "a.json";
a.primaryMain
Posted by: Guest on June-16-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language