Importar Arquivo 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
Attractive Alpaca