I have a parent component that retrieves data from a service that I have to be calling every X time. I do this with a setInterval
This parent component passes through @Input
various parameters to a child component that is the one that displays the view. I need that each time the data is updated (when receiving service data) in the parent component, refresh the child's view so that they are reflected in the.
Parent component:
ngOnInit() {
setInterval(this.getData(), 5000);
}
getData(): void {
this.allData = this.zoneService.getDatas();
}
html:
<app-place *ngIf="allData" [distancia]="allData?.metros"
[texto]="allData?.message"
[zona]="allData?.zoneSelected?.id"></app-place>
Child component:
export class PlaceComponent implements OnInit {
@Input() distancia: number;
@Input() zona: number;
@Input() texto: string;