I am having issues with my HTML components updating after a form is submitted. Any suggestions would be helpful on my current code to make sure when a form is submitted it updates the correct view. The view will update with the correct information once I refresh my screen; however that is not what I want.
data.service.ts
create(resource: any) {
return this.http.post(this.url, resource,
{headers: this.header, responseType: 'text' as 'json'})
}
update(entryId: any, resource: any) {
return this.http.put(this.url + entryId, resource,
{headers: this.header, responseType: 'text' as 'json'})
}
form.ts
submit(resource) {
if (this.id) {
this.service.update(this.id, resource)
.subscribe(response => {
console.log(response)
});
this.router.navigate(['../../'], {relativeTo: this.route});
}
else this.service.create(resource)
.subscribe(response => {
console.log(response)
this.router.navigate(['../'], {relativeTo: this.route});
})
}
frontendView.ts
ngOnInit(){
this.otherService.getAll()
.subscribe(otherEntry => {
this.otherEntry = otherEntry;
});
}