This repository has been archived by the owner on May 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
48 lines (43 loc) · 1.46 KB
/
app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/// <reference path="typings/angular2/angular2.d.ts" />
import {Component, View, bootstrap, Injectable, httpInjectables, NgFor} from 'angular2/angular2';
import {PokemonDataService} from 'pokemonDataService';
import {LocalstorageService} from 'localstorageService';
// Annotation section
@Component({
selector: 'my-app',
appInjector: [LocalstorageService, PokemonDataService]
})
@View({
template: `
<div class="container">
<div class="row">
<div class="col s12">
<h2 class="header">Listing</h2>
<div class="collection">
<!-- Make this list scrollable -->
<!-- Add a way to filter it -->
<a class="collection-item" *ng-for="#pokemon of pokedex" href="{{pokemon.resource_uri}}">
<!-- Cache this images into localstorage and base64 them All !-->
<img src="http://www.pokemontrash.com/pokedex/images/x-y5g/{{pokemon.number}}.png" alt=""/><span class="badge">{{pokemon.number}}</span> {{pokemon.name}}
</a>
</div>
</div>
</div>
</div>
`,
directives : [NgFor]
})
// Component controller
class MyAppComponent {
pokemonDataService:any;
pokedex:any;
constructor(pokemonDataService: PokemonDataService) {
console.log("App : Constructor");
var self = this;
this.pokemonDataService = pokemonDataService;
this.pokemonDataService.getPokedex().subscribe(pokedex => {
this.pokedex = pokedex.pokemon;
});
}
}
bootstrap(MyAppComponent, [httpInjectables]);