diff --git a/src/app/owners/owner-add/owner-add.component.ts b/src/app/owners/owner-add/owner-add.component.ts index f76ee9cb..b35b0020 100644 --- a/src/app/owners/owner-add/owner-add.component.ts +++ b/src/app/owners/owner-add/owner-add.component.ts @@ -34,7 +34,6 @@ export class OwnerAddComponent implements OnInit { owner: Owner; errorMessage: string; - added_success: boolean = false; constructor(private ownerService: OwnerService, private router: Router) { this.owner = {}; @@ -47,8 +46,8 @@ export class OwnerAddComponent implements OnInit { owner.id = null; this.ownerService.addOwner(owner).subscribe( new_owner => { - this.added_success = true; - return this.owner = new_owner; + this.owner = new_owner; + this.gotoOwnersList(); }, error => this.errorMessage = error ); diff --git a/src/app/owners/owner-edit/owner-edit.component.ts b/src/app/owners/owner-edit/owner-edit.component.ts index 2aecfec3..1097e60f 100644 --- a/src/app/owners/owner-edit/owner-edit.component.ts +++ b/src/app/owners/owner-edit/owner-edit.component.ts @@ -47,6 +47,7 @@ export class OwnerEditComponent implements OnInit { } onSubmit(owner) { + var that = this; this.ownerService.updateOwner(owner.id.toString(), owner).subscribe( get_result, get_error @@ -61,7 +62,8 @@ export class OwnerEditComponent implements OnInit { function get_result(update_status) { console.log(update_status); if (update_status.status === 204) { - return console.log('update success'); + console.log('update success'); + that.gotoOwnerDetail(owner); } else { return console.log('update failed'); } @@ -72,4 +74,6 @@ export class OwnerEditComponent implements OnInit { this.router.navigate(['/owners', owner.id]); } + + }