Я хочу сделать пост-запрос (который позволяет пользователю добавлять в любой ребенок семьи)
это пост-запрос в службе пользователя
postChild( familyId: number , child: Child) {
return this.http.post(this.baseUrl + 'users/' + this.authService.decodedToken.nameid + '/families/' + familyId + '/children', child);
}
member-child-add-component
postChild( child: Child ) {
if (this.childForm.valid) {
this.child = Object.assign({}, this.childForm.value);
this.userService.postChild( this.familyId , this.child).subscribe(() => {
}, error => {
this.alertify.error(error);
}, () => {
this.authService.login(this.user).subscribe(() => {
this.router.navigate(['/CampList']);
});
} );
}
}
путь маршрутизатора
{path: 'family' ,
children: [
{path: ':id' ,
children: [
{ path: '', component: MemberFamilyDetailsComponent , resolve: {family: MemberFamilyDetailResolver}},
{path: 'addChild' , component: MemberChildAddComponent },
{path: 'mychildlist' ,
children: [
{path: '' , component: MemberChildListComponent , resolve: {child: MemberchildforuserListResolver}},
]},
], },
],
},
в html компонент add
[routerLink]="['/family/',family.id,'addChild']"