Angular SyntaxError:输入意外结束

时间:2019-01-10 01:33:53

标签: angular typescript

我试图从我的API中获取商品详细信息,并尝试在Angular应用程序中显示它。但是当我获取数据时,我的数据对象上出现了该错误

消息:“输入意外结束”

stack:“ SyntaxError:在FlorsComponent.push ../ src / app / manager / flors / flors.component.ts.FlorsComponent.editZone(http://localhost:4200/main.js:1703:14)↵中,输入↵的意外结束在Object.eval [作为handleEvent](ng:///AppModule/FlorsComponent.ngfactory.js:20:27)↵在handleEvent({http://localhost:4200/vendor.js:43342:41)↵在callWithDebugContext(http://localhost:4200/vendor.js:44435:25)↵在Object.debugHandleEvent [作为handleEvent] (http://localhost:4200/vendor.js:44138:12)在dispatchEvent(http://localhost:4200/vendor.js:40801:25)在HTMLButtonElement。http://localhost:4200/vendor.js:41245:38)在ZoneDelegate.push ../ node_modules / zone.js / dist /zone.js.ZoneDelegate.invokeTask(http://localhost:4200/vendor.js:59000:36)↵at Object.onInvokeTask(http://localhost:4200/polyfills.js:2743:31)“

从API返回的结果

{
"cubeAreaID":1019,
"repoID":16,
"cubeAreaName":"hkjh",
"createdBy":14,
"updatedBy":null,
"createdDate":"2019-01-09T22:12:37.5991778",
"updatedDate":null,"isActive":1
}

flor.ts

export interface Flor {
cubeAreaID: number;
repoID: number;
cubeAreaName: string;
createdBy: number;
updatedBy: number;
createdDate: string;
updatedDate: string;
isActive: number;
}

Service.ts

getFlorById(zoneID): Observable<Flor> {
return this.http.get<Flor>(this.baseUrl + 'CubeArea/GetCubeAreaById/?CubeAreaId=' + zoneID);

}

flor.component.ts

editZone(cubeAreaID) {

this.florService.getFlorById(cubeAreaID).subscribe(
  data => {
    this.flor = data;
  },
  error => {
    this.alertify.error(error);
  }
);

}

在flor.component.ts中的data =>对象中显示“输入意外结束”错误。它没有返回erorr!。我调试时就可以看到它。该代码甚至没有输入错误=>部分。它正在正确获取cubeAreaID,试图获取数据,并且该数据从块中消失。

PS:当此代码使请求api正确运行并正确返回响应时,如顶部所写。

我检查了其他问题,但库伦特为我的问题找到了答案。通常他们会谈论json语法错误,但我会发现任何错误

0 个答案:

没有答案
相关问题