📌  相关文章
📜  导入文件 json angular 12 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:07.258000             🧑  作者: Mango

代码示例1
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