toute les questions fini + ajout d'élément dans pokdetail
This commit is contained in:
@@ -2,12 +2,13 @@ import { Component } from '@angular/core';
|
||||
//import { constructor } from 'jasmine';
|
||||
import { PokeDetail, Pokemon } from '../pokemon';
|
||||
import { PokeAPIServiceService } from '../poke-apiservice.service';
|
||||
import { PokeShareInfoService } from '../poke-share-info.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-my-component',
|
||||
templateUrl: './my-component.component.html',
|
||||
styleUrl: './my-component.component.css',
|
||||
providers: [PokeAPIServiceService]
|
||||
providers: [PokeAPIServiceService]
|
||||
})
|
||||
export class MyComponentComponent {
|
||||
id: string;
|
||||
@@ -16,7 +17,8 @@ export class MyComponentComponent {
|
||||
pokeDetail : PokeDetail;
|
||||
pokes : Pokemon[] = [];
|
||||
|
||||
constructor(private pokeService: PokeAPIServiceService){
|
||||
constructor(private pokeService: PokeAPIServiceService,
|
||||
private PokeShareInfoService: PokeShareInfoService){
|
||||
/*this.pokes.push(new Pokemon('1', "Bulbizarre"));
|
||||
this.pokes.push(new Pokemon('2', "Herbizarre"));
|
||||
this.pokes.push(new Pokemon('3', "Florizarre"));
|
||||
@@ -42,6 +44,34 @@ export class MyComponentComponent {
|
||||
this.id=this.selectedPokeId;
|
||||
if (this.selectedPokeId != ''){
|
||||
this.pokeService.getPokemonInfo(this.selectedPokeId).subscribe(data=> this.pokeDetail = data)
|
||||
//this.PokeShareInfoService.setValue(this.selectedPokeId);
|
||||
}
|
||||
}
|
||||
|
||||
previous_pokemon(){
|
||||
var n_id: number = +this.id
|
||||
if(n_id>1){
|
||||
this.id = n_id-1+""
|
||||
}
|
||||
else{
|
||||
this.id = ""+this.pokes.length
|
||||
}
|
||||
this.selectedPokeId = this.id
|
||||
this.pokeService.getPokemonInfo(this.selectedPokeId).subscribe(data=> this.pokeDetail = data)
|
||||
|
||||
}
|
||||
next_pokemon(){
|
||||
var n_id: number = +this.id
|
||||
if(n_id<this.pokes.length){
|
||||
this.id = n_id+1+""
|
||||
}
|
||||
else{
|
||||
this.id = "1"
|
||||
}
|
||||
this.selectedPokeId = this.id
|
||||
this.pokeService.getPokemonInfo(this.selectedPokeId).subscribe(data=> this.pokeDetail = data)
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user