1
屬性「後」我對原始異常:無法讀取的不確定在角2
的問題無法在提交表單讀取屬性在角2
的不確定的「後」,一個是所謂的,這裏的功能是代碼
onSubmit() {
console.log("onsubmit->", this.addForm.value);
let addArray = this.addForm.value;
this._employeeservice.addEmployeeCollection(addArray)
.subscribe(sample => {
this.dbemp.push(sample);
});
this.addForm.reset();
this.SubmitToast();
}
addEmployeeCollection()
代碼是在這裏
addEmployeeCollection(addArray: EmployeeSchema) {
let url: string = Constants.DOMAIN + Constants.CREATE_EMPLOYEE_ROUTE;
console.log('addArray at emplyee service', addArray)
var body = addArray;
let headers = new Headers();
headers.append('Content-Type', 'application/json');
let options = {
headers: headers
};
let token = localStorage.getItem('realtoken');
options.headers.set('Authorization', ` ${token}`);
return this.http.post(url, body, options).map(res => res.json()).catch(this._errorHandler);
}
http://stackoverflow.com/questions/34450410/typeerror- can not-read-property-post-of-undefined-in-null –
請提供您實例化this.http服務的代碼。 – eminlala
Http服務沒有被注入。 –