【发布时间】:2015-03-11 20:14:38
【问题描述】:
我正在尝试从控制器获取数据 像这样:
public IEnumerable<Custom> Search(string searchText = "")
{
return new[] { new Custom { Name = "a", Id = 1 }, new Custom { Name = "b", Id = 1 }, new Custom { Name = "c", Id = 3 } };
}
但是角度给了我这个
米 你 s 一世 C p ○ r 吨 一种 l . C ○ n 吨 r ○ l l e r s . C 你 s 吨 ○ 米 [ ]
我尝试添加 http.headers 但没有。 我的代码:
var musicportal = angular.module('musicportal', []);
musicportal.controller('SearchController', ['$scope', '$http', function ($scope, $http) {
$scope.answer = "awesome";
$scope.search = function (text) {
$scope.answer = text;
$scope.pms = [];
$http.post('/Home/Search', { searchText: text }).
success(function (data, status, headers, config) {
$scope.pms = data;
});
$scope.searchText = "";
}
}]);
【问题讨论】:
-
看看这个post能不能帮到你。
-
您是否从该控制器调用中获取 JSON?
-
我尝试在 angular.foreach 视图中使用 $scope.pms
标签: asp.net-mvc angularjs http-post