I am developing a project in angular, in which I upload a file in json formats and show it in a table. Until now I have three components that are:
- UploadComponent
- TableComponent
- TableDetalleComponent
My question is how from UploadComponent I can send the data to TableComponent and TableDetalleComponent, this is my code:
import { Component, OnInit } from '@angular/core';
import { TableComponent } from '../table/table.component';
import { MatPaginator, MatSort, MatTableDataSource} from '@angular/material';
import {tableInf} from './upload.model';
import {UploadService} from '../services/upload.service';
@Component({
selector: 'app-upload',
templateUrl: './upload.component.html',
styleUrls: ['./upload.component.css']
})
export class UploadComponent implements OnInit {
displayedColumns: string[] = ['noMaquina', 'cantidadDatos','promedioTCH', 'tiempoTrabajo', 'promedioVelocidad', 'noDescargas' ];
fileText;
datos;
datosServices;
nombre:any="";
mee=this;
fileUpload(event) {
var reader = new FileReader();
reader.readAsText(event.srcElement.files[0]);
var me = this;
reader.onload = function () {
me.fileText = reader.result;
var json = me.fileText;
me.datos = JSON.parse(json)
me.nombre=me.datos;
}
this.pruebas();
}
public pruebas(){
alert("Mis datos: " + this.nombre.id);
debugger;
}
constructor() {}
ngOnInit() {
}
}
Please can you give me a help !!