こんにちは私は、データベース内のブランドテーブルにコードと名前があります。 Angularjsを使ってブランドリストを取得しようとしています。私のWebサービスでanglejsのデータベースからデータを読み込む方法C#
var app = angular.module("myApp", []);
app.controller("CateCtrl", function ($scope, $http) {
$scope.ShowBrandList();
//Show from DB
$scope.ShowBrandList = function() {
var httpreq = {
method: 'POST',
url: 'Brand.aspx/GetBrandList',
headers: {
'Content-Type': 'application/json; charset=utf-8',
'dataType': 'json'
},
data: {}
}
$http(httpreq).success(function (response) {
$scope.brandList = response.d;
})
};
});
私Brand.aspx.csで
[WebMethod]
public List<Master_BrandBLL> GetBrandList()
{
return Master_BrandBLL.GetALLBrands();
}
Brand.aspx
で
<div ng-app="myApp" ng-controller="CateCtrl">
<table class="table table-bordered table-hover table-striped" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>
No
</th>
<th>
Code
</th>
<th>
Name
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="brand in brand.brandList">
<td>
{{$index}}
</td>
<td>
{{ brand.Code }}
</td>
<td>
{{ brand.Name }}
</td>
</tr>
</tbody>
</table>
</div>
jQueryを使って細かい作業。しかし、それはangularjsで何も表示することはできません。
'$ scope.brandList = response.dを;'なぜ ".D" と – PinBack