Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 8前端未将捕获的数据/字段发送到后端_Angular_Go_Angular8 - Fatal编程技术网

Angular 8前端未将捕获的数据/字段发送到后端

Angular 8前端未将捕获的数据/字段发送到后端,angular,go,angular8,Angular,Go,Angular8,我目前正在重写一个应用程序,该应用程序将有一个Angular 8前端(作为我的代码学习),该前端将与连接到MSSQL数据库的Go后端交互。 我可以成功显示数据库中的数据。 但是,当尝试更新接收到的数据时,看起来字段/数据没有发送到Go后端。 我已经使用Postman测试了Go后端API,效果很好。 关于下面的代码可能有什么问题,或者我可以做些什么来调试它,有什么建议吗 rest-api.service.ts httpOptions = { headers: new HttpHeaders({

我目前正在重写一个应用程序,该应用程序将有一个Angular 8前端(作为我的代码学习),该前端将与连接到MSSQL数据库的Go后端交互。 我可以成功显示数据库中的数据。 但是,当尝试更新接收到的数据时,看起来字段/数据没有发送到Go后端。 我已经使用Postman测试了Go后端API,效果很好。 关于下面的代码可能有什么问题,或者我可以做些什么来调试它,有什么建议吗

rest-api.service.ts

httpOptions = {
headers: new HttpHeaders({
  'Content-Type': 'application/json'
 //'Content-Type': 'Application-Token : this.getToken()' 
})
}  
updateDetails(ref, details): Observable<Details> {
return this.http.put<Details>(this.apiURL + '/details-edit/' + ref,    JSON.stringify(details), this.httpOptions)
.pipe(
retry(1),
catchError(this.handleError)
)
}
details-component.html

<div class="form-group">
<input type="text" [(ngModel)]="details.Run_Date" class="form-control" placeholder="Run_Date">
</div>   
 <div class="form-group">
<button class="btn btn-success btn-lg btn-block" (click)="updateDetails()">Update Details</button>
</div>

更新详细信息

我希望捕获的\编辑的字段用作我的GO MSSQL查询中占位符的值。在您的
.html
中,您使用的是ngModel作为
详细信息
,但在您的组件.ts中,您有
详细数据

组件.ts
中,
updateDetails
函数有一个参数。确保使用
控制台.log
执行该函数,因为在
.html

另外,我不知道您是否希望后端接收字符串。您应该通过
put
发送数据,而不使用
JSON.stringify

我希望这有帮助

<div class="form-group">
<input type="text" [(ngModel)]="details.Run_Date" class="form-control" placeholder="Run_Date">
</div>   
 <div class="form-group">
<button class="btn btn-success btn-lg btn-block" (click)="updateDetails()">Update Details</button>
</div>