Skip to content

Commit

Permalink
Favorite一覧出力を作成 refs #15
Browse files Browse the repository at this point in the history
  • Loading branch information
sinmetal committed Jun 11, 2013
1 parent 69106ec commit a757922
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
20 changes: 11 additions & 9 deletions html/guestbook/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
<table class="table">
<thead>
<tr>
<td>No</td>
<td>CategoryId</td>
<td>ItemId</td>
<td>Name</td>
<th>No</th>
<th>Email</th>
<th>Pokemon</th>
<th>Nickname</th>
<th>Created</th>
</tr>
</thead>
<tbody ng-repeat="s in stores">
<tbody ng-repeat="f in favos">
<tr>
<td>{{$index}}</td>
<td>{{s.CategoryId}}</td>
<td>{{s.ItemId}}</td>
<td>{{s.Name}}</td>
<td>{{$index + 1}}</td>
<td>{{f.email}}</td>
<td>{{f.pokemonName}}</td>
<td>{{f.nickname}}</td>
<td>{{f.created}}</td>
</tr>
</tbody>
</table>
Expand Down
14 changes: 7 additions & 7 deletions process/favorite/favorite.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
type Favorite struct {
Id string `json:"id" datastore:"-"`
PokemonName string `json:"pokemonName"`
Nickname string `json:nickname`
Email string `json:email`
Nickname string `json:"nickname"`
Email string `json:"email"`
Created time.Time `json:"created"`
}

Expand All @@ -40,15 +40,15 @@ func decodeFavorite(r io.ReadCloser) (*Favorite, error) {
}

func getAllFavorites(c appengine.Context) ([]Favorite, error) {
Favorites := []Favorite{}
ks, err := datastore.NewQuery("Favorite").Order("Created").GetAll(c, &Favorites)
favos := []Favorite{}
ks, err := datastore.NewQuery("Favorite").Order("Created").GetAll(c, &favos)
if err != nil {
return nil, err
}
for i := 0; i < len(Favorites); i++ {
Favorites[i].Id = ks[i].StringID()
for i := 0; i < len(favos); i++ {
favos[i].Id = ks[i].StringID()
}
return Favorites, nil
return favos, nil
}

func init() {
Expand Down
3 changes: 2 additions & 1 deletion script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@

app.controller('GuestBookListController', ['$scope', '$resource', function($scope, $resource) {
var Favorite = $resource("/favorite");
$scope.stores = Favorite.query(function() {
$scope.favos = Favorite.query(function() {
console.log("success favorite query");
console.log($scope.favos);
}, function(){
console.log("error favorite query");
});
Expand Down

0 comments on commit a757922

Please sign in to comment.