我是完全新的角2和形式的概念。我正在嘗試將POST數據發送到POST API調用。這樣Angular 2:如何使用表格
POST API:http://localohot:8080/ **********
組件:
user: any = {
id: null,
gender: null,
mstatus: null,
birthdate: null,
bloodgroup: null
}
userName: any = {
id: null,
personId: null,
displayName: '',
prefix: null,
givenName: null
}
userAddressJSON: any = {
id: null,
personId: null,
address1: null,
address2: null,
cityVillage: null
}
var form = new FormData();
form.append('userid', new Blob(['' + uid], { type: 'application/json' }));
form.append('user', new Blob([JSON.stringify(this.user)], { type: 'application/json' }));
form.append('userName', new Blob([JSON.stringify(this.userName)], { type: 'application/json' }));
form.append('userAddress', new Blob([JSON.stringify(this.userAddressJSON)], { type: 'application/json' }));
在這裏,我不知道如何使API調用。 在我們的舊應用程序中,他們使用jQuery中的表單數據POST。現在,我想我做舊的應用程序的形式POST他們發送這樣
------WebKitFormBoundarybAWvwmP2VtRxvKA7
Content - Disposition: form - data; name = "userid"; filename = "blob"
Content - Type: application/json
------WebKitFormBoundarybAWvwmP2VtRxvKA7
Content - Disposition: form - data; name = "user"; filename = "blob"
Content - Type: application/json
------WebKitFormBoundarybAWvwmP2VtRxvKA7
Content - Disposition: form - data; name = "userName"; filename = "blob"
Content - Type: application/json
------WebKitFormBoundarybAWvwmP2VtRxvKA7
Content - Disposition: form - data; name = "userAddress"; filename = "blob"
Content - Type: application/json
任何一個可以幫助我如何做,表單POST在角2
做同樣的角2
我建議你看看官方文檔https://angular.io/docs/ts/latest/guide/server-communication.html – abhishekkannojia
angular2的文檔非常好,非常詳細,它也有一個步驟一步教程。我會先看看。 – Igor