【发布时间】:2017-03-01 05:38:06
【问题描述】:
我对这段代码有疑问我有来自我的 asp.net web api 的 json 数据。我无法通过 angularjs 获取这些数据。如您所见,代码;
<!DOCTYPE html>
<html ng-app="myapp">
<head>
<title ng-bind="helloAngular"></title>
<script src="~/Scripts/angular.min.js"></script>
<script>
var myapp = angular.module('myapp', []);
myapp.controller('myController', function ($scope, $htpp){
$htpp.get({
method:'GET',
url:'http://localhost:50972/api/product'})
.success(function (response) {
$scope.result = response.statusText
});
});
</script>
</head>
<body ng-controller="myController">
<table border="1">
<tr ng-repeat="product in response">
<td>{{product.id}}</td>
<td>{{product.name}}</td>
<td>{{product.type}}</td>
</tr>
</table>
</body>
</html>
【问题讨论】:
-
您得到什么错误或数据作为响应?你的 web api 代码在哪里查看你返回的内容?
标签: angularjs json asp.net-mvc asp.net-web-api