Skip to content

Commit

Permalink
Recibiendo parametros por URL
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJonaCode committed Sep 25, 2020
1 parent 159a940 commit 6368289
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/app/components/heroe/heroe.component.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { HeroesService } from '../../servicios/heroes.service'

@Component({
selector: 'app-heroe',
templateUrl: './heroe.component.html'
})
export class HeroeComponent implements OnInit {
export class HeroeComponent {

heroe: any = {};


constructor( private activatedRoute: ActivatedRoute,
private _heroesService: HeroesService
) {

constructor() { }
this.activatedRoute.params.subscribe( params =>{
this.heroe = this._heroesService.getHeroe( params['id'] );
} );

ngOnInit(): void {
}
}

}
3 changes: 3 additions & 0 deletions src/app/servicios/heroes.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export class HeroesService{
return this.heroes;
}

getHeroe( idx: string){
return this.heroes[idx];
}

}

Expand Down

0 comments on commit 6368289

Please sign in to comment.