答案 0 :(得分:0)
我可以为您提供一些url示例,因为您必须创建一个表单模板并接收数据并将其发送到您的服务器,您可以按照以下url来创建表单组。
https://www.sitepoint.com/angular-forms/
因此,为了将数据发送到服务器,您可以创建服务,这是一个示例:
https://www.metaltoad.com/blog/angular-5-making-api-calls-httpclient-service
基本上在您的服务中,在其构造函数中添加以下行: 构造函数(私有http:HttpClient){}
提出请求:
let url = 'urltoyourserver/';
return this.http.get(url, params);
答案 1 :(得分:0)
这是调用诸如上载之类的事件的代码
docker login container-registry.oracle.com
您的服务。TS
const formData: FormData = new FormData();
const params = Object.assign({}, {
Id: 01010,
FileName: file.name,
FilePath: '', // this will be in Web API, so no need to pass from UI.
CreatedBy: 'test-user'
});
formData.append('uploadFile', file, params.FileName);
formData.append('myObjectClass', JSON.stringify(params));
this.myService.uploadAttachments(formData).subscribe (resp => {
// your code here
},
(error) => {
console.log('POST ERROR in method uploadAttachments: ' + error.error);
}
);
}
在Web API中:
uploadAttachments(formData: any): any {
const headers = new HttpHeaders();
/** In Angular 5, including the header Content-Type can invalidate your request */
headers.append('Content-Type', 'multipart/form-data');
headers.append('Accept', 'application/json');
return this.http.post(this.baseURL +
'Controller/UpdateInsertAttachments', formData,
{headers: headers});