Skip to content

Instantly share code, notes, and snippets.

@siuling88
Last active July 28, 2021 20:50
Show Gist options
  • Save siuling88/f4776d365ff0e977771764fbc35699cf to your computer and use it in GitHub Desktop.
Save siuling88/f4776d365ff0e977771764fbc35699cf to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { GenteService } from '../../services/gente.service';
@Component({
selector: 'formacion-detalle',
templateUrl: 'detalle.component.html',
})
export class DetalleComponent implements OnInit {
persona: any = {};
constructor(
private _genteService: GenteService,
private route: ActivatedRoute
) {}
ngOnInit() {
const routeParams = this.route.snapshot.paramMap;
const productIdFromRoute = Number(routeParams.get('id'));
this._genteService.getPersonas().subscribe((data) => {
this.persona = data.gente[productIdFromRoute];
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment