JsonResult 未从 Angular 4 中识别出来
JsonResult is not identify from Angular 4
您好,我正在使用 VS 2015 Angular 4。我有通用的控制器方法来发出 http 请求。
public JsonResult Get(string endpoint)
{
// from Rest sharp
var result = _restsharpClient.Get<List<object>>(endpoint);
return Json(result,JsonRequestBehavior.AllowGet);
}
在我的 angular class 中,我调用此方法进行 http 请求
return this.http
.get('/Home/Get?endpoint='http://examplecode/API/gettestmethod')
.map((response: Response) => {
console.log(response);
return <myclass[]>response.json();
当我调试代码时,我 return 成功地将数据写入结果变量。但是对于 angular,我得到一个空数组。有什么想法吗?
首先创建数组变量并调用this.variable。
Public result:any=[];
return this.http
.get('/Home/Get?endpoint='http://examplecode/API/gettestmethod')
.map((response: Response) => {
console.log(response);
this.result=response.json(); });
您好,我正在使用 VS 2015 Angular 4。我有通用的控制器方法来发出 http 请求。
public JsonResult Get(string endpoint)
{
// from Rest sharp
var result = _restsharpClient.Get<List<object>>(endpoint);
return Json(result,JsonRequestBehavior.AllowGet);
}
在我的 angular class 中,我调用此方法进行 http 请求
return this.http
.get('/Home/Get?endpoint='http://examplecode/API/gettestmethod')
.map((response: Response) => {
console.log(response);
return <myclass[]>response.json();
当我调试代码时,我 return 成功地将数据写入结果变量。但是对于 angular,我得到一个空数组。有什么想法吗?
首先创建数组变量并调用this.variable。
Public result:any=[];
return this.http
.get('/Home/Get?endpoint='http://examplecode/API/gettestmethod')
.map((response: Response) => {
console.log(response);
this.result=response.json(); });