Javascript 发送POST请求-angular4

Javascript 发送POST请求-angular4,javascript,html,angular,typescript,Javascript,Html,Angular,Typescript,我将使用angular 4向django后端api提交一个表单,但当我单击save按钮时,并没有任何操作发生。我监控了后端,没有任何传入请求。我无法找出我的代码哪里出错,请遵循我的代码: addEmployee.component.ts: 从“/../Employee”导入{Employee}; 从“/add employee.service”导入{AddEmployeeService}; 从“@angular/core”导入{Component,OnInit}; 从“/../../servic

我将使用angular 4向django后端api提交一个表单,但当我单击save按钮时,并没有任何操作发生。我监控了后端,没有任何传入请求。我无法找出我的代码哪里出错,请遵循我的代码:

addEmployee.component.ts:

从“/../Employee”导入{Employee};
从“/add employee.service”导入{AddEmployeeService};
从“@angular/core”导入{Component,OnInit};
从“/../../services/data.service”导入{DataService};
@组成部分({
选择器:“app addemployee”,
templateUrl:'./addemployee.component.html',
样式URL:['./addemployee.component.css']
})
导出类AddemployeeComponent实现OnInit{
职位:阵列;
马哈利亚斯:阵列;
课程:阵列;
职员:数组;
构造函数(私有数据服务:数据服务,私有AddEmployeeService:AddEmployeeService){}
恩戈尼尼特(){
this.dataService.getAllMahaleyahs().subscribe(
data=>this.mahalyas=data
);
this.dataService.getAllCourses().subscribe(
data=>this.courses=data
);
这是.dataService.getAllJobs().subscribe(
data=>this.jobs=data
);
}
onSave(){
this.dataService.saveEmployee(this.employee);
}
}
Employee.ts:

导出类员工
{
建造师
( 
公众id:号码,
公共名称:string,
公共级:字符串,
公共marial_状态:字符串,
子项的公共编号:字符串,
公共配偶工作地点:字符串,
公共父级\u状态:字符串,
公共直升机状态:字符串,
向mahaleyah转让的公开日期:字符串,
公共广播:字符串,
公共移动电话号码:string,
公共就业类型:字符串,
公众资格:字符串,
公共额外资格:字符串,
注:字符串,
公共职务:字符串,
公共先前的e_mahaleyah:string,
公共课程:字符串){}
}
addEmployee.component.html:



الإسم:
نوع التعيين:
معين
متعاون
الحالة الإجتماعية:
متزوج
اعزب
مطلق
ارمل
الوظيفة:
{{job.name}
المؤهل:
المؤهل الإضافي:
العنوان:
المحلية السابقة:
{{mahaleyah.name}
تاريخ النقل للمحلية:
الحالة الصحية:
عدد الأطفال:
مكان عمل الزوج:
رقم الهاتف:
الدورات: 
{{course.name}
حالة الوالدين:
ملاحظات:
关闭
data.service.ts:

从'@angular/core'导入{Injectable,Input};
从'@angular/Http'导入{Http,Headers};
从“../kgs/Kg”导入{Kg};
导入'rxjs/add/operator/map';
@可注射()
导出类数据服务{
baseUrl:string='1〕http://localhost:8000/kgms/';
构造函数(私有http:http){}
/*Getters开始了*/
公共getAllEmployees(){
返回this.http.get(this.baseUrl+'employees/'))
.map(res=>res.json());
}
公共getAllKgs(){
返回this.http.get(this.baseUrl+'kgs/')
.map(res=>res.json());
}
公共getAllStudents(){
返回this.http.get(this.baseUrl+'students/')
.map(res=>res.json());
}
公共getAllAssessments(){
返回this.http.get(this.baseUrl+'asses/'))
.map(res=>res.json());
}
公共getAllMahaleyahs(){
返回this.http.get(this.baseUrl+'mahaleyahs/')
.map(res=>r
onSave(){
  this.dataService.saveEmployee(this.employee).subscribe((response) => {
     // do something with 'response'
  });
}