Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
Source by www.freakyjolly.com #
 
PREVIOUS NEXT
Tagged: #import #file #json #angular
ADD COMMENT
Topic
Name
6+7 =