Skip to content

Commit

Permalink
store一覧を画面表示できるようになった #5
Browse files Browse the repository at this point in the history
  • Loading branch information
sinmetal committed May 19, 2013
1 parent 9504c32 commit 0904919
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 16 deletions.
48 changes: 35 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,41 @@
<body>
<div ng-controller="MainController">
<h2>Hello AngularJS !!</h2>
<form ng-submit="submit()">
<select ng-model="entryForm.categoryId" ng-options="c.id as c.name for c in categories" ng-change="changeCategory()">
<option value="">-- chose category --</option>
</select>
<br />
<select ng-model="entryForm.itemId" ng-options="i.id as i.name for i in items">
<option value="">-- chose item --</option>
</select>
<br />
<input type="text" ng-model="entryForm.name"></input>
<br />
<button type="submit" class="btn">submit</button>
</form>
<div>
<table class="table">
<thead>
<tr>
<td>No</td>
<td>CategoryId</td>
<td>ItemId</td>
<td>Name</td>
</tr>
</thead>
<tbody ng-repeat="s in stores">
<tr>
<td>{{$index}}</td>
<td>{{s.CategoryId}}</td>
<td>{{s.ItemId}}</td>
<td>{{s.Name}}</td>
</tr>
</tbody>
</table>
</div>
<div>
<form ng-submit="submit()">
<select ng-model="entryForm.categoryId" ng-options="c.id as c.name for c in categories" ng-change="changeCategory()">
<option value="">-- chose category --</option>
</select>
<br />
<select ng-model="entryForm.itemId" ng-options="i.id as i.name for i in items">
<option value="">-- chose item --</option>
</select>
<br />
<input type="text" ng-model="entryForm.name"></input>
<br />
<button type="submit" class="btn">submit</button>
</form>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="//code.angularjs.org/1.0.6/angular.min.js"></script>
Expand Down
3 changes: 2 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

$scope.stores = Store.query(function() {
console.log("success store query");
console.log($scope.stores);
console.log($scope.stores[0].CategoryId);
}, function(){
console.log("error store query");
});
console.log($scope.stores);

$scope.changeCategory = function() {
$scope.items = List.query({id : $scope.entryForm.categoryid}, function(){
Expand Down
3 changes: 1 addition & 2 deletions process/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,5 @@ func get(w http.ResponseWriter, r *http.Request) {
}

c.Infof("%s", j)
//fmt.Fprintf(w, "%s", j)
fmt.Fprintf(w, "%s", "[{\"id\" : \"1\", \"name\" : \"キャベツ\"}]")
fmt.Fprintf(w, "%s", j)
}

0 comments on commit 0904919

Please sign in to comment.