This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const chunkArrayInGroups = (arr, size) => ( | |
arr.reduce( | |
(acc, cv, index) => ( | |
!((index / size) % 1) | |
? [a, [cv]] | |
: [ | |
...acc.slice(0, acc.length - 1), | |
[ | |
...acc[acc.length - 1], | |
cv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "Stmt1481924239005", | |
"Effect": "Allow", | |
"Action": [ | |
"cloudformation:CancelUpdateStack", | |
"cloudformation:ContinueUpdateRollback", | |
"cloudformation:CreateChangeSet", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="pokemon_frame" > | |
<h3> | |
#{{pokemon.id}} | |
</h3> | |
<img src="{{pokemon.sprite}}"> | |
<p> | |
{{pokemon.name}} | |
</p> | |
</div> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class AppComponent { | |
pokemon: Pokemon; | |
constructor(private pokedexService: PokedexService) {} | |
ngOnInit(){ | |
this.pokedexService.getPokemon(1).subscribe( | |
result => { this.pokemon = result } | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class PokedexService { | |
private baseUrl: string ='https://pokeapi.co/api/v2/'; | |
constructor(private http: Http) { } | |
getPokemon(index:number) : Observable<Pokemon> { | |
return this.http.get(`${this.baseUrl}pokemon/${index}`) | |
.map((result:Response) => result.json()) | |
.map((res) => {return new Pokemon(index, res.name, res.sprites.front_default)}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Pokemon { | |
constructor( | |
public id:number, | |
public name:string, | |
public sprite:string){} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ngOnInit(){ | |
this.pokedexService.getPokemon(1).subscribe( | |
result => {this.pokemon = result } | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ngOnInit(){ | |
this.pokemon = this.pokedexService.getPokemon(1); | |
console.log(this.pokedexService.getPokemon(1)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class AppComponent{ | |
pokemon | |
constructor(private pokedexService: PokedexService) {} | |
ngOnInit(){ | |
this.pokemon = this.pokedexService.getPokemon(1) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1> | |
{{pokemon}} | |
</h1> |
NewerOlder